Retry(fn,
delay,
timeout,
args=None,
wait_fn=time.sleep,
_time_fn=time.time)
| source code
|
Call a function repeatedly until it succeeds.
The function fn is called repeatedly until it doesn't
throw RetryAgain anymore. Between calls a delay, specified by
delay , is inserted. After a total of timeout
seconds, this function throws RetryTimeout.
delay can be one of the following:
-
callable returning the delay length as a float
-
Tuple of (start, factor, limit)
-
RETRY_REMAINING_TIME to sleep until the timeout
expires (this is useful when overriding
wait_fn to wait for an external event)
-
A static delay as a number (int or float)
- Parameters:
fn (callable) - Function to be called
delay - Either a callable (returning the delay), a tuple of (start,
factor, limit) (see _RetryDelayCalculator), RETRY_REMAINING_TIME or a number (int or float)
timeout (float) - Total timeout
wait_fn (callable) - Waiting function
- Returns:
- Return value of function
|