Celery result.get 超时

发布于 2024-11-30 04:33:31 字数 532 浏览 3 评论 0原文

我有两个不同的 django 项目,分别是 projAprojB,每个项目都有自己的 celery 守护进程在不同的队列上运行,但相同的虚拟主机,projA 有一个任务 taskA > 和 projB 有一个任务 taskB,我尝试从 taskA 内部运行 taskB 例如,

@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)

我可以在 projB 的日志中看到 taskB 在 a 内完成第二,但taskA继续等待结果并在20秒后超时

对于后端我有rabbitmq。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

涫野音 2024-12-07 04:33:31

设置结果后端解决了问题

CELERY_RESULT_BACKEND = "amqp"
CELERY_AMQP_TASK_RESULT_EXPIRES = 1000 

IMO 如果未设置结果后端 result.get 应该抛出错误或至少记录警告

尽管 celery 2.3 确实会抛出错误,如此处所述 https://github.com/ask/django-celery/issues/66

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文