- 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)¶
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)¶
Create a KazooRetry instance 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 – 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)¶
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
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