简体   繁体   English

Django芹菜在检查数据是否准备好时总是返回false

[英]Django celery always returns false when checking if data is ready

I have setup Django with Celery running with rabbitmq. 我已经设置了Django与Celery一起运行rabbitmq。

I have implemented following example in my project: http://docs.celeryproject.org/en/master/django/first-steps-with-django.html 我在我的项目中实现了以下示例: http//docs.celeryproject.org/en/master/django/first-steps-with-django.html

When i run a simple test in two terminal windows the results are as following: 当我在两个终端窗口中运行一个简单的测试时,结果如下:

# Terminal 1
>>> from Exercise.tasks import *
>>> result = add.delay(2,3)
>>> result
<AsyncResult: e6c92297-eea2-4f99-8902-1446ac74a6bb>
>>> result.ready()
False

# Terminal 2
$ celery -A Website3 worker -l info
[2014-10-02 14:39:59,269: INFO/MainProcess] Received task: Exercise.tasks.add[464249dd-ab89-4099-badd-9190a147310f]
[2014-10-02 14:39:59,271: INFO/MainProcess] Task Exercise.tasks.add[464249dd-ab89-4099-badd-9190a147310f] succeeded in 0.0010875929147s: 5

Obviously the data is completed, but i am not able to receive this data. 显然数据已经完成,但我无法收到这些数据。

What am i doing wrong here? 我在这做错了什么?

Do you have your result backend set up properly? 您是否正确设置了结果后端? http://docs.celeryproject.org/en/master/userguide/configuration.html#task-result-backend-settings http://docs.celeryproject.org/en/master/userguide/configuration.html#task-result-backend-settings

Celery needs this set up properly to store state and results of async tasks. Celery需要正确设置以存储异步任务的状态和结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM