5

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!

Community
  • 1
  • 1
dcoffey3296
  • 2,504
  • 3
  • 24
  • 34

1 Answers1

3

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

aganders3
  • 5,838
  • 26
  • 30
  • Is there a good way to get the pid(s) for running subprocesses? – dcoffey3296 Jan 27 '12 at 21:43
  • Possibly, but I'm not aware of it. Maybe you could keep track of them when they are created? Edit: actually, the code in your link (by dmarkey) seems like it might work, or? – aganders3 Jan 27 '12 at 21:48