oslo_service.loopingcall.
BackOffLoopingCall
(f=None, *args, **kw)¶Bases: oslo_service.loopingcall.LoopingCallBase
Run a method in a loop with backoff on error.
The passed in function should return True (no error, return to initial_interval), False (error, start backing off), or raise LoopingCallDone(retvalue=None) (quit looping, return retvalue if set).
When there is an error, the call will backoff on each failure. The backoff will be equal to double the previous base interval times some jitter. If a backoff would put it over the timeout, it halts immediately, so the call will never take more than timeout, but may and likely will take less time.
When the function return value is True or False, the interval will be multiplied by a random jitter. If min_jitter or max_jitter is None, there will be no jitter (jitter=1). If min_jitter is below 0.5, the code may not backoff and may increase its retry rate.
If func constantly returns True, this function will not return.
To run a func and wait for a call to finish (by raising a LoopingCallDone):
timer = BackOffLoopingCall(func) response = timer.start().wait()
Parameters: |
|
---|---|
Raises: | LoopingCallTimeout if time spent doing error retries would exceed timeout. |
start
(initial_delay=None, starting_interval=1, timeout=300, max_interval=300, jitter=0.75, min_interval=0.001)¶oslo_service.loopingcall.
DynamicLoopingCall
(f=None, *args, **kw)¶Bases: oslo_service.loopingcall.LoopingCallBase
A looping call which sleeps until the next known event.
The function called should return how long to sleep for before being called again.
start
(initial_delay=None, periodic_interval_max=None, stop_on_exception=True)¶oslo_service.loopingcall.
FixedIntervalLoopingCall
(f=None, *args, **kw)¶Bases: oslo_service.loopingcall.LoopingCallBase
A fixed interval looping call.
start
(interval, initial_delay=None, stop_on_exception=True)¶oslo_service.loopingcall.
FixedIntervalWithTimeoutLoopingCall
(f=None, *args, **kw)¶Bases: oslo_service.loopingcall.LoopingCallBase
A fixed interval looping call with timeout checking mechanism.
start
(interval, initial_delay=None, stop_on_exception=True, timeout=0)¶oslo_service.loopingcall.
LoopingCallDone
(retvalue=True)¶Bases: exceptions.Exception
Exception to break out and stop a LoopingCallBase.
The poll-function passed to LoopingCallBase can raise this exception to break out of the loop normally. This is somewhat analogous to StopIteration.
An optional return-value can be included as the argument to the exception; this return-value will be returned by LoopingCallBase.wait()
oslo_service.loopingcall.
LoopingCallTimeOut
¶Bases: exceptions.Exception
Exception for a timed out LoopingCall.
The LoopingCall will raise this exception when a timeout is provided and it is exceeded.
oslo_service.loopingcall.
RetryDecorator
(max_retry_count=-1, inc_sleep_time=10, max_sleep_time=60, exceptions=())¶Bases: object
Decorator for retrying a function upon suggested exceptions.
The decorated function is retried for the given number of times, and the sleep time between the retries is incremented until max sleep time is reached. If the max retry count is set to -1, then the decorated function is invoked indefinitely until an exception is thrown, and the caught exception is not in the list of suggested exceptions.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.