Skip to main content
 首页 » 编程设计

python之rabbitMQ 重启时 celery 撤销丢失

2025年05月04日28youxin

我们正在使用 celery eta tasks 来安排 FAR(比如几个月)的任务。 现在使用 rabbitMQ 后端,因为 mongo 后端在 worker 重启时确实松开了此类任务。

实际上,rabbitMQ 后端的任务似乎在 celery 和 rabbitMQ 重启后仍然存在,但是 revoke 消息似乎在 rabbitMQ 重启时丢失了。 我猜如果撤销消息丢失,那些应该被杀死的 eta 任务仍然会执行。

请您参考如下方法:

这可能对文档 ( Persistent Revokes ) 有帮助:

The list of revoked tasks is in-memory so if all workers restart the list of revoked ids will also vanish. If you want to preserve this list between restarts you need to specify a file for these to be stored in by using the –statedb argument to celery worker:

$ celery -A proj worker -l info --statedb=/var/run/celery/worker.state