'Redis queue run function on last retry

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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source