【问题标题】:Celery tasks should be queued on worker getting lost芹菜任务应该在工人迷路时排队
【发布时间】:2018-04-22 12:35:49
【问题描述】:

我正在使用 django-celery 3.2 和 celery 3.1.25。 我添加了以下设置 -

CELERY_TASK_ACKS_LATE = True
task_reject_on_worker_lost = True

如果我将 celery 4.x 与 django-celery 3.2 一起使用,应用程序会导致以下错误并且无法加载

ImportError: 没有名为 vine.five 的模块

复制步骤

触发一些任务,并从日志中获取它们的 pid。我使用 kill 命令随机杀死一个工人(pid)。

预期行为

任务应该回到队列并由同一个或其他工作人员拾取。

实际行为

任务丢失了。

【问题讨论】:

    标签: django task celery worker


    【解决方案1】:

    您不能将 django-celery 与较新版本的 celery 一起使用。

    以前版本的 Celery 需要一个单独的库来与 Django 一起工作,但从 3.1 开始不再是这种情况。 Django 现在支持开箱即用,因此本文档仅包含集成 Celery 和 Django 的基本方法。

    当您提到使用 celery 4.x 时,您可以在此处 (http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html) 阅读有关如何在 Django 中使用 celery。

    【讨论】:

    • 有没有办法绕过 django-celery,并为 django 应用程序使用 celery 4.x 功能?
    • 正如文件在前两句话中所说的那样。 Previous versions of Celery required a separate library to work with Django, but since 3.1 this is no longer the case. Django is supported out of the box now so this document only contains a basic way to integrate Celery and Django. 所以第一步是删除 django-celery 然后修复任何可能发生的配置错误。
    猜你喜欢
    • 2020-01-04
    • 2014-06-09
    • 2021-02-21
    • 1970-01-01
    • 2014-07-14
    • 2020-10-07
    • 1970-01-01
    • 2011-12-29
    • 2019-07-08
    相关资源
    最近更新 更多