MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / retry

Function retry

tensorflow/contrib/learn/python/learn/datasets/base.py:133–160  ·  view source on GitHub ↗

Simple decorator for wrapping retriable functions. Args: initial_delay: the initial delay. max_delay: the maximum delay allowed (actual max is max_delay * (1 + jitter). factor: each subsequent retry, the delay is multiplied by this value. (must be >= 1). jitter: to

(initial_delay,
          max_delay,
          factor=2.0,
          jitter=0.25,
          is_retriable=None)

Source from the content-addressed store, hash-verified

131
132@deprecated(None, 'Use the retry module or similar alternatives.')
133def retry(initial_delay,
134 max_delay,
135 factor=2.0,
136 jitter=0.25,
137 is_retriable=None):
138 """Simple decorator for wrapping retriable functions.
139
140 Args:
141 initial_delay: the initial delay.
142 max_delay: the maximum delay allowed (actual max is
143 max_delay * (1 + jitter).
144 factor: each subsequent retry, the delay is multiplied by this value.
145 (must be >= 1).
146 jitter: to avoid lockstep, the returned delay is multiplied by a random
147 number between (1-jitter) and (1+jitter). To add a 20% jitter, set
148 jitter = 0.2. Must be < 1.
149 is_retriable: (optional) a function that takes an Exception as an argument
150 and returns true if retry should be applied.
151
152 Returns:
153 A function that wraps another function to automatically retry it.
154 """
155 return _internal_retry(
156 initial_delay=initial_delay,
157 max_delay=max_delay,
158 factor=factor,
159 jitter=jitter,
160 is_retriable=is_retriable)
161
162
163def _internal_retry(initial_delay,

Callers 3

StartMethod · 0.85
WaitInternalMethod · 0.85
CommunicateMethod · 0.85

Calls 1

_internal_retryFunction · 0.85

Tested by

no test coverage detected