kazoo.retry¶
Public API¶
- class kazoo.retry.KazooRetry(max_tries=1, delay=0.1, backoff=2, max_jitter=0.8, max_delay=3600, ignore_expire=True, sleep_func=<built-in function sleep>, deadline=None, interrupt=None)[source]¶
Helper for retrying a method in the face of retry-able exceptions
- __init__(max_tries=1, delay=0.1, backoff=2, max_jitter=0.8, max_delay=3600, ignore_expire=True, sleep_func=<built-in function sleep>, deadline=None, interrupt=None)[source]¶
Create a KazooRetry instance for retrying function calls
Parameters:
- max_tries – How many times to retry the command.
- delay – Initial delay between retry attempts.
- backoff – Backoff multiplier between retry attempts. Defaults to 2 for exponential backoff.
- max_jitter – Additional max jitter period to wait between retry attempts to avoid slamming the server.
- max_delay – Maximum delay in seconds, regardless of other backoff settings. Defaults to one hour.
- ignore_expire – Whether a session expiration should be ignored and treated as a retry-able command.
- interrupt – Function that will be called with no args that may return True if the retry should be ceased immediately. This will be called no more than every 0.1 seconds during a wait between retries.
- __call__(func, *args, **kwargs)[source]¶
Call a function with arguments until it completes without throwing a Kazoo exception
Parameters:
- func – Function to call
- args – Positional arguments to call the function with
Params kwargs: Keyword arguments to call the function with
The function will be called until it doesn’t throw one of the retryable exceptions (ConnectionLoss, OperationTimeout, or ForceRetryError), and optionally retrying on session expiration.
- exception kazoo.retry.ForceRetryError[source]¶
Raised when some recipe logic wants to force a retry.