1

I am using djcelery and django's admin site. If I want to stop a djcelery task that has started, do I use revoke, terminate or kill and what is the difference?

Chillar Anand
  • 27,936
  • 9
  • 119
  • 136
Jamneck
  • 443
  • 8
  • 14

1 Answers1

2

You should use terminate to kill an already started task.

revoke:

>>> from celery.task.control import revoke
>>> revoke(task_id)

When a worker receives a revoke request it will skip executing the task, but it won’t terminate an already executing task.

terminate:

>>> from celery.task.control import revoke
>>> revoke(task_id, terminate=True)

If terminate is set the worker child process processing the task will be terminated. The default signal sent is TERM. Terminating a task also revokes it.

kill:

This is different from the above two. KILL is used to kill workers

ps auxww | grep 'celery worker' | awk '{print $2}' | xargs kill -9
Chillar Anand
  • 27,936
  • 9
  • 119
  • 136