django celery 终止任务的子进程

发布于 2024-12-29 13:05:26 字数 685 浏览 4 评论 0原文

这是我之前问题的后续问题: 用 Celery 取消已经执行的任务?

celery.task.control.revoke({task_id}, terminate=True) 

确实杀死我运行任务的工人。我现在遇到的问题是,我的任务正在运行子进程,当任务被撤销时,这些子进程不会终止。

这篇文章由 dmarkey 发表 http:// /dmarkey.com/wordpress/2011/09/07/killing-child-processes-of-celery-tasks-on-a-timeout/ 是我见过的最接近我想要做的事情,除了我不想在超时时杀死,而是当我用task_id撤销()时。

似乎我所拥有的只是(字符串)task_id,有没有办法杀死这样的子进程?感谢您的帮助 - 我在这方面没有我想要的那么多经验,浏览文档是一个挑战!

This is a follow-up question to my previous question:
Cancel an already executing task with Celery?

celery.task.control.revoke({task_id}, terminate=True) 

does indeed kill my worker running the task. I am now having the issue that my task is running subprocesses that do not die when the task is revoked.

This post by dmarkey
http://dmarkey.com/wordpress/2011/09/07/killing-child-processes-of-celery-tasks-on-a-timeout/
is the closest I've seen to what I want to do, except I don't want to kill on timeout, but rather when I revoke() with the task_id.

Seeming that all I have is the (String) task_id, is there anyway to kill such subprocesses? Thanks for your help - I don't have quite as much experience with this as I'd like, navigating the docs is a challenge!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅黛梨妆こ 2025-01-05 13:05:26

尝试为 on_revoked 杀死任务的子进程。

Try setting a callback for on_revoked that kills the child processes of the task.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文