这是我的项目结构:
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
我从设置目录开始芹菜。它会启动,但不会添加fe目录中提到的任务。这是我的celeryconfig文件:
from __future__ import absolute_import
from celery import Celery
from datetime import timedelta
app = Celery('fj',
broker='amqp://',
backend='amqp://',
include=['tasks'])
# Optional configuration, see the application user guide.
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
)
if __name__ == '__main__':
app.start()
我不知道如何让芹菜发现所有目录和子目录中的任务。请帮忙。你知道吗
通过对Celery类的实例调用autodiscover\u tasks(),可以自动覆盖任务:
第一个参数是要搜索的包的列表,关键字参数“related\u name”可以包含包含任务的模块的名称(默认值为“tasks”)。你知道吗
要搜索的软件包列表可以是django的INSTALLED\u APPS列表。你知道吗
这里的documentation用于自动发现\u任务()
相关问题 更多 >
编程相关推荐