Retry is a plugin to add the ability for Henson applications to automatically retry messages that fail to process.
Retry registers itself as an error callback on the
Application instance. When doing so, it inserts itself
at the beginning of the list of error callbacks. It does this so that it can
prevent other callbacks from running.
If you have an error callback that you want to run even when retrying a message, you will need to manually inject it into the list of error callbacks after initializing Retry.
Retry provides a couple of settings to control how many times a message will be
RETRY_TIMEOUT work in tandem. If values are
specified for both, whichever limit is reached first will cause Henson to stop
retrying the message. By default, Henson will try forever (yes, this is
||A number that, if provided, will be used in conjunction with the number of retry attempts already made to calculate the total delay for the current retry. Defaults to 1.|
||A coroutine that encapsulates the functionality
needed to retry the message.
||The number of seconds to wait before scheduling a
||An exception or tuple of exceptions that will cause
Henson to retry the message. Defaults to
||The maximum number of times that a Henson
application will try to process a message before
marking it as a failure. if set to 0, the message
will not be retried. If set to None, the limit will
be controlled by
||The maximum number of seconds during which a message
can be retried. If set to None, the limit will be
from henson import Application from henson.contrib.retry import Retry async def print_message(app, message): print(message) app = Application('retryable-application', callback=my_callback) app.settings['RETRY_CALLBACK'] = print_message Retry(app)
Somwhere inside the application:
from henson.contrib.retry import RetryableException async def my_callback(app, message): raise RetryableException
A class that adds retries to an application.
Exception to be raised when a message should be retried.