通过任务 ID 重试 celery 中的任务
我启动了很多任务,但其中一些尚未完成(763 个任务),处于 PENDING 状态,但系统未处理任何内容... 是否可以通过给 celery 提供 task_id 来重试此任务?
I've launched a lot of tasks, but some of then hasn't finished (763 tasks), are in a PENDING state, but the system isn't processing anything...
It's possible to retry this tasks giving celery the task_id?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不能。
您只能从内部重试任务,而不能从外部执行此操作。
在这种情况下,最好的办法是使用相同的参数再次运行任务类型,这样您将执行相同的作业,但使用标识您的进程/任务的新 PID。
还要记住,celery PENDING 状态不仅意味着任务正在等待执行,而且可能是未知的。
http://celeryq.org/docs/userguide/tasks.html#pending
我希望这能有所帮助
You can't.
You can retry a task only from inside itself, you can't do it from outside.
The best thing to do in this case is to run again the task type with the same args, in this way you will do the same JOB but with a new PID that identify your process/task.
Remember also that the celery PENDING state not means only that the task is waiting for execution, but maybe that is unknown.
http://celeryq.org/docs/userguide/tasks.html#pending
I hope this could help
现在,在设置
celery.conf.update(result_extended=True)
后,它可以保留传递给任务的参数:This works now after setting
celery.conf.update(result_extended=True)
which persists the arguments passed to the task: