I am using the python-rq Retry() functionality with the on_failure callback. The problem is that the on_failure function runs after every failure on the job so it does not allow handling the last retry differently from the previous reties.
In my case I would like to flag my job as failed only if it fails all retries. Is that possible? I am pretty stuck here so I have not tried anything else.
So far I have tried to use the FailedJobRegistry() to count the fails of the job but it doesn't seem to support such functionality.
I managed to solve this issue by checking in the
on_failurefunction that the job has0orNoneretries before running the actualon_failurelogic.So my my job was enqueued as:
and the
report_failure()as: