一旦工人被强行关闭,如何在 celery 中重新启动 运行 任务和待处理任务?

How to restart running task and pending task in celery once worker is forcefully shutdown?

目前我在 celery 中 运行ning 任务,需要 10 到 15 分钟才能完成,但问题是我如何重新启动当前 运行ning 在 worker 中的任务以及当前不在 worker 中的任务运行正在等待 运行 任务,而我强行停止了 worker 或以防我的服务器崩溃或停止。现在发生的情况是,如果我再次启动芹菜,它不会启动最后一个 运行ning 任务或剩余任务。

您可以做的一件事是启用 acks_late on the task. Additionally, it's probably worthwhile to read their FAQ section on acks late and retry.

@app.task(acks_late=True)
def task(*args, **kwargs):
    ...