我正在玩芹菜教程的演示案例。但是,当我启动任务应用程序时,结果显示为禁用,如下所示。任何想法?
celery --app=plmtcheck worker -l info
Then I see:
- ** ---------- .> app: plmtcheck:0x7f9fd2fdf160
- ** ---------- .> transport: amqp://guest@localhost:5672//
- ** ---------- .> results: disabled
I have seen the result is ready.
[2014-05-05 16:16:55,382: INFO/MainProcess] Connected to amqp://guest@127.0.0.1:5672//
[2014-05-05 16:16:55,389: INFO/MainProcess] mingle: searching for neighbors
[2014-05-05 16:16:56,401: INFO/MainProcess] mingle: all alone
[2014-05-05 16:16:56,422: WARNING/MainProcess] celery@D-NYC-00552088-Linux ready.
[2014-05-05 16:17:27,726: INFO/MainProcess] Received task: plmtcheck.add[7ea5a501-1085-48b7-8f7e-dac8ac2c5377]
[2014-05-05 16:17:27,759: INFO/MainProcess] Task plmtcheck.add[7ea5a501-1085-48b7-8f7e-dac8ac2c5377] succeeded in 0.032166894000056345s: 37
我的代码就是
from celery import Celery
app = Celery('plmtcheck', backend='amqp', broker='amqp://')
@app.task
def add(x, y):
return x + y
if __name__ == '__main__':
app.worker_main()
安装django-celery-results
包,然后将其添加到settings.py
INSTALLED_APPS = [
...
'django_celery_results',
...
]