I'm trying to use celery in my project. when I use from celery.task.control import revoke
the PyCharm highlight control
and warn me cannot find reference 'control' in __init__.py
and also PyCharm adds broken line under revoke
and warn me Unresolved reference revoke
.
But when I run the project, celery is working great without any problem with calling tasks or revoking them. My question is why PyCharm warns me and is it possible in future any problem happen about that?
celery.py:
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hamclassy.settings')
app = Celery('hamclassy')
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
project/__init__.py:
from __future__ import absolute_import, unicode_literals
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app
__all__ = ['celery_app']