Celery: Auto Discovery Does Not Find Tasks Module In App
Solution 1:
Add CELERY_IMPORTS
to your settings.py:
CELERY_IMPORTS = ('testapp.tasks',)
Import all the tasks in testapp.tasks.__init__
file
Then Celery will import all tasks from testapp.tasks folder and name them as they are
Solution 2:
This was a bug in django-celery 2.5.4, please upgrade to 2.5.5!
Solution 3:
For any one who stumbles here looking for similar problem solution.
In my case it was switching from old module bases INSTALLED_APPS
setting to a new AppConfig based configuration.
New applications should avoid default_app_config. Instead they should require the dotted path to the appropriate AppConfig subclass to be configured explicitly in INSTALLED_APPS.
To fix this you should change the way you feed packages to celery, as stated here in the 2248 Celery issue:
from django.apps import apps
app.autodiscover_tasks(lambda: [n.name for n in apps.get_app_configs()]
Instead of the old Celery 3 way:
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
Solution 4:
I had the same issue with django 1.4.1 celery 3.0.9 and fixed it by naming the task.
@task() -> @task(name='testapp.tasks.add')
Solution 5:
In my case, I couldn't figure out the problem until I tried to import the tasks in shell (python
or python manage.py shell
).
>>>from project_name.tasks import task_add
Post a Comment for "Celery: Auto Discovery Does Not Find Tasks Module In App"