Sometimes, we want to cancel an already executing task with Celery and Python.
In this article, we’ll look at how to cancel an already executing task with Celery and Python.
How to cancel an already executing task with Celery and Python?
To cancel an already executing task with Celery and Python, we can use the revoke function.
For instance, we write
from celery.task.control import revoke
revoke(task_id, terminate=True)
to call revoke with the task_id of the task to stop.
And we set terminate to True to terminate the task.
Conclusion
To cancel an already executing task with Celery and Python, we can use the revoke function.