SimpleRetry(expected,
fn,
delay,
timeout,
args=None,
wait_fn=time.sleep,
_time_fn=time.time)
| source code
|
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, ...)".
|