- class kazoo.retry.KazooRetry(max_tries=1, delay=0.1, backoff=2, max_jitter=0.4, max_delay=60.0, ignore_expire=True, sleep_func=<built-in function sleep>, deadline=None, interrupt=None)¶
Helper for retrying a method in the face of retry-able exceptions
- __init__(max_tries=1, delay=0.1, backoff=2, max_jitter=0.4, max_delay=60.0, ignore_expire=True, sleep_func=<built-in function sleep>, deadline=None, interrupt=None)¶
KazooRetryinstance for retrying function calls.
max_tries – How many times to retry the command. -1 means infinite tries.
delay – Initial delay between retry attempts.
backoff – Backoff multiplier between retry attempts. Defaults to 2 for exponential backoff.
max_jitter – Percentage of jitter to apply to each retry’s delay to ensure all clients to do not hammer the server at the same time. Between 0.0 and 1.0.
max_delay – Maximum delay in seconds, regardless of other backoff settings. Defaults to one minute.
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)¶
Call a function with arguments until it completes without throwing a Kazoo exception
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.
Reset the attempt counter
Return a clone of this retry manager
- exception kazoo.retry.ForceRetryError¶
Raised when some recipe logic wants to force a retry.
- exception kazoo.retry.RetryFailedError¶
Raised when retrying an operation ultimately failed, after retrying the maximum number of attempts.
- exception kazoo.retry.InterruptedError¶
Raised when the retry is forcibly interrupted by the interrupt function