Modified docs to use emphasize the best way to configure exception handlers.

main
Selwin Ong 7 years ago
parent c639018fb9
commit 8b57842ea3

@ -21,24 +21,13 @@ handlers. This makes it possible to replace the default behaviour (sending
the job to the `failed` queue) altogether, or to take additional steps when an
exception occurs.
To do this, register your custom exception handler to an RQ worker as follows:
This is how you register custom exception handler(s) to an RQ worker:
{% highlight python %}
with Connection():
q = Queue()
w = Worker([q])
w.push_exc_handler(my_handler)
w.work()
{% endhighlight %}
While the exception handlers are a FILO stack, most times you only want to
register a single handler. Therefore, for convenience, you can pass it to the
constructor directly, too:
from rq.handlers import move_to_failed_queue # RQ's default exception handler
{% highlight python %}
with Connection():
w = Worker([q], exception_handlers=[my_handler, self.move_to_failed_queue])
...
w = Worker([q], exception_handlers=[my_handler, move_to_failed_queue])
...
{% endhighlight %}
The handler itself is a function that takes the following parameters: `job`,

Loading…
Cancel
Save