How do I stop retrying when a particular exception occurs?

47 Views Asked by At

I'm enqueing my tasks like this:

from redis import Redis
from rq import Queue, Retry

queue = Queue(connection=Redis())
queue.enqueue("path.to.my.func", retry=Retry(max=3), on_failure=my_failure)

And then on the failure callback I want to stop the next retry if a particular exception occurs:

def my_failure(job, connection, type, value, traceback):
    if type == MyException:
        # do not continue retrying!

I'm not sure if the on_failure is the right way to do it.

0

There are 0 best solutions below