I’m using Task Inheritance in celery to retry (max_retries: 3) on certain exceptions, and log failures.
Is on_failure called on each failed attempt or only after the last attempt (the 3rd in my case)?
def __call__(self, *args, **kwargs):
try:
return self.run(*args, **kwargs)
except InterfaceError as exc:
self.retry(exc=exc, countdown=5, max_retries=3)
def on_failure(self, exc, task_id, args, kwargs, einfo):
log(exc) # This is a gross simplification of the logging
Advertisement
Answer
Tested this and on_failure is only run after the retries have all failed.
So, using the example given above, on_failure is called after the 3rd failure.