Simple way to revoke tasks of a chain?

787 views
Skip to first unread message

Tobias Brückner

unread,
Nov 27, 2013, 8:00:23 AM11/27/13
to celery...@googlegroups.com
Hello world!

Maybe I am missing something but is there a simple way at some point in the future to revoke all tasks of a chain?

Problem: From a web service I create a chain of possibly long running tasks and at some point in the future a user might want to stop processing of these tasks.

The system is still in development and at the moment I create the chain, collect all the task IDs und store them in a database. Kind of like this:

res = (task.s() | task.s() | task.s() | task.s() | task.s())()
tasks = []
while res:
    tasks.append(res.id)
    res = res.parent
save_them_to_the_db(tasks)


Then, some time in the future, the user might want to stop processing of these tasks, clicks on his Abort-Button and the system would get the task IDs from the DB and I do basically something like this:

for t in tasks:
    celery.control.revoke(t, terminate=True, signal="SIGABRT")


(I send SIGABRT’s because I use a simple signal handler to interrupt the work inside of the task.)

Now, I wonder, is there a simpler way to revoke all the tasks of the chain? Revoking a single task is something simple like this:

res = result.AsyncResult(task_id)
res.revoke()

Or:

celery.control.revoke(task_id)


Would it be possible (maybe in future releases) to simply store the ID of the group in the database and then, when the user wants to stop all the tasks, just do something like:

c = chain.load(id)
c.revoke()

Or something like that. Or am I missing something here?

Oh, and while we are at it, let me say that from what I have seen so far Celery looks fantastic! :-)

Regards,
Tobias.

Wiktor Stribiżew

unread,
May 29, 2023, 6:38:36 AM5/29/23
to celery-users
Did you solve this? I also cannot REVOKE all the tasks inside the chain. Once I launch a task, and try to revoke (with terminate=True) it, I can see the tasks popping up in the Flower UI, all with SUCCESS state, and then the cancelled task appears as REVOKED. :(
Reply all
Reply to author
Forward
0 new messages