问题
I have two different django projects say projA
and projB
, each have its own celery daemon running on separate queues but same vhost, projA have a task taskA
and projB have a task taskB
, I try to run taskB
from inside taskA
e.g.
@task(routing_key='taskA')
def taskA(event_id):
# do some work , then call taskB and wait for result
result = send_task('taskB',routing_key='taskB')
res = result.get(timeout=20)
I can see in logs of projB that taskB finished within a second, but taskA keeps on waiting for result and times out after 20 seconds
For backend I have rabbitmq.
回答1:
Setting the result back-end fixed the problem
CELERY_RESULT_BACKEND = "amqp"
CELERY_AMQP_TASK_RESULT_EXPIRES = 1000
IMO if result back-end is not set result.get should throw error or at-least log a warning
Though celery 2.3 does throw error as described here https://github.com/ask/django-celery/issues/66
来源:https://stackoverflow.com/questions/7111040/celery-result-get-times-out