python - Errors running celery with Django -
this project structure:
fj_project |-- fj | |-- celerybeat.pid | |-- celerybeat-schedule | |-- celeryconfig.pyc | |-- fe | | |-- admin.py | | |-- forms.py | | |-- __init__.py | | |-- models.py | | |-- tasks.py | | |-- tests.py | | |-- views.py | |-- feja | | |-- celeryconfig.pyc | | |-- __init__.py | | |-- settings | | | |-- base.py | | | |-- celeryconfig.py | | | |-- __init__.py | | | |-- local.py | | | |-- production.py | | | |-- tasks.py | | | `-- test.py | | |-- urls.py | | |-- wsgi.py | |-- fj.sqlite3 | |-- __init__.py | |-- manage.py | |-- site-media | `-- templates | |-- 400.html |-- makefile `-- requirements |-- local.txt -- production.txt
i start celery settings directory. , starts doesn't add tasks mentioned in fe directory. celeryconfig file:
from __future__ import absolute_import celery import celery datetime import timedelta app = celery('fj', broker='amqp://', backend='amqp://', include=['tasks']) # optional configuration, see application user guide. app.conf.update( celery_task_result_expires=3600, ) if __name__ == '__main__': app.start()
i unable figure out how make celery discover tasks in directories , sub-directories. please help.
you can autodscover tasks invoking autodiscover_tasks() on instance of celery class:
app.autodiscover_tasks(['fe'])
first argument list of packages search , keyword argument "related_name" can contain name of module holding tasks (default "tasks").
list of packages search can django's installed_apps list.
here documentation autodiscover_tasks()
Comments
Post a Comment