Amir Rustamzadeh
Amir Rustamzadeh

Reputation: 4528

How does Celery handle task failures within a chain?

What happens when a Celery task within a chain fails?

When the failed task is retried with success, does it simply resume from where it was within a chain?

For example:

my_chain = (task1.s() | task2.s() | task3.s())
my_chain.apply_async((**params))

If task2 fails and retried with success, would task3 then be executed?

There is an old question that touches on the subject (Retrying celery failed tasks that are part of a chain), and a Github issue and commit applied to version 3.0.4 of Celery that makes Task.retry forward the chain links to remedy this issue. However, I am unable to find any concrete documentation that explains behavior of Celery during this situation.

Definitely, no mention of it within the Celery documentation Retrying sections (http://celery.readthedocs.org/en/latest/userguide/tasks.html#retrying, http://celery.readthedocs.org/en/latest/reference/celery.app.task.html#celery.app.task.Task.retry)

Upvotes: 1

Views: 2079

Answers (1)

user2097159
user2097159

Reputation: 892

I believe the following snippet is the closest thing to describing this.

"When you call retry it will send a new message, using the same task-id, and it will take care to make sure the message is delivered to the same queue as the originating task.

When a task is retried this is also recorded as a task state, so that you can track the progress of the task using the result instance (see States)."

I believe where it state that the task state is tracked best describes what you are looking for.

I also know this based on first hand experience

Upvotes: 2

Related Questions