Utility functions for retrying function calls with a timeout.
Exception |
|
Retry again. |
Exception |
|
Retry loop timed out. |
Function |
|
A wrapper over SimpleRetry implementing a count down. |
Function |
|
Call a function repeatedly until it succeeds. |
Function |
|
Retries calling a function up to the specified number of times. |
Function |
|
A wrapper over Retry implementing a simpler interface. |
Constant | RETRY |
Undocumented |
Class | _ |
Calculator for increasing delays. |
A wrapper over SimpleRetry
implementing a count down.
Where Retry
fixes the time, after which the command is assumed to be failing, this function assumes the total number of tries.
See Also | |
Retry |
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 overridingwait_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 |
args | Undocumented |
wait | Waiting function |
_time | Undocumented |
Returns | |
Return value of function |
Retries calling a function up to the specified number of times.
Parameters | |
max | Maximum number of retries. |
exception | Exception class which is used for throwing the final exception. |
fn:callable | Function to be called (up to the specified maximum number of retries. |
*args | Undocumented |
**kwargs | Undocumented |
A wrapper over Retry
implementing a simpler interface.
All the parameters are the same as for Retry
, except it has one extra argument: expected, which can be either a value (will be compared with the result of the function, or a callable (which will get the result passed and has to return a boolean). If the test is false, we will retry until either the timeout has passed or the tests succeeds. In both cases, the last result from calling the function will be returned.
Note that this function is not expected to raise any retry-related exceptions, always simply returning values. As such, the function is designed to allow easy wrapping of code that doesn't use retry at all (e.g. "if fn(args)" replaced with "if SimpleRetry(True, fn, ...)".
See Also | |
Retry |