The final task in the celery 3.1.18

I have a django application with some celery tasks, I am looking at a worker with

celery -A myapp worker --loglevel=INFO --concurrency=10

I run the task with task.deploy(), but when I try to complete the task withcelery.task.control.revoke(task_id, terminate=True)

I get

[2015-07-27 14:27:04,736: ERROR/MainProcess] Task task[80e06e87-f254-4c0b-bea5-5c21540777ab] raised unexpected: Terminated(15,)
Traceback (most recent call last):
  File "/home/blake/projects/venv/myapp/lib/python2.7/site-packages/billiard/pool.py", line 1674, in _set_terminated
    raise Terminated(-(signum or 0))
Terminated: 15

I was looking for a message about this error, but I only found a 3 year post that didn't help me at all.

I use

celery==3.1.18
kombu==3.0.25
billiard==3.3.0.20

So, how do I successfully complete an already running task?

EDIT: the task, however, ends, but the code stops executing due to an exception and for some reason, except it catches Exception

try:
    revoke(task_id, terminate=True)
except Terminated:
    pass
+4
source share
1 answer

When creating a task, you need to specify an exception that will be thrown inside the task

from billiard.exceptions import Terminated

@task(throws=(Terminated,))
def task():
   ...
+1
source

All Articles