orokusaki
orokusaki

Reputation: 57118

Django Celery - how to perform a function AFTER retries have exhausted

I added some code to my task's on_failure which deletes an object. My intention was to delete the object after the max retries occurred, but on_failure is called once per failure of the run method, rather than after failure of all retries. Is there another place to put this sort of functionality (e.g., def after_exhaustion(...)).

Upvotes: 1

Views: 482

Answers (1)

mher
mher

Reputation: 10846

The task context has a retries field which is the number of times the task has been retried. You can use it to determine when to delete your object.

Upvotes: 3

Related Questions