python - Celery中的task_reject_on_worker_lost和task_acks_late有什么不同

标签 python task celery

您能否解释一下我必须使用什么:task_reject_on_worker_losttask_acks_late 以及它们有何不同? 为什么当task_acks_late为True时,Celery在异常后不再次运行任务?

在 Celery 文档中:

Even if task_acks_late is enabled, the worker will acknowledge tasks when the worker process executing them abruptly exits

“突然退出”是什么意思?会引发异常吗?

task_acks_lateTruetask_reject_on_worker_lostTrue 时,Celery 何时重试任务?

最佳答案

如果您希望它在异常后重试,您可以将参数传递给装饰器。

@app.task(max_retries=10)
def task(*args, **kwargs):
    #stuff

突然退出是指worker被杀死,并非异常(exception)。如果您使用task_acks_late,那么工作人员将在任务结束时而不是开始时从队列中删除该项目。但是,如果工作进程被终止,即使任务尚未完成,任务仍然会被确认。如果发生上述事件,task_reject_on_worker_lost 将重新排队消息,这样您就不会丢失任务。

来源: http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_reject_on_worker_lost

http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-acks-late

您应该能够毫无问题地使用这两个设置。

关于python - Celery中的task_reject_on_worker_lost和task_acks_late有什么不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45045980/

相关文章:

python - celery 击败不接受周期性任务

python - Django Celery - 无法连接到 amqp ://guest@127. 0.0.8000:5672//

python - 如何在Docker中运行不属于预先构建的Docker镜像的新Jupyter Notebook文件?

python - 使用 Flask 初始化路由中使用的对象

python - 我可以将 luigi 与 Python celery 一起使用吗

java - 如何为 Ant 任务创建嵌套元素?

c# - 为什么 CollectionViewSource.GetDefaultView(...) 从任务线程内部返回错误的 CurrentItem?

python - Scrapy 案例 : Incremental Update of Items

python - Pandas :某些列中的总和值

c# - Task.ContinueWith() 是否保证运行?