Celery result.get times out

白昼怎懂夜的黑 提交于 2019-12-23 04:42:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!