Use wait_random_exponential from tenacity 4.4.0
Now that we depend on tenacity >=4.4.0, we can use the library's version of the wait_random_exponential wait strategy in place of our own. Change-Id: I13d3222808a98ef7e333f58df931c8f950ac1221 Depends-On: https://review.openstack.org/556309
This commit is contained in:
parent
6ccfb11df9
commit
ec189f4657
|
@ -115,34 +115,11 @@ def serialize_input_data(input_data):
|
|||
return {'input_data': _serialize(input_data)}
|
||||
|
||||
|
||||
class wait_random_exponential(tenacity.wait_exponential):
|
||||
"""Random wait strategy with a geometrically increasing amount of jitter.
|
||||
|
||||
Implements the truncated binary exponential backoff algorithm as used in
|
||||
e.g. CSMA media access control. The retry occurs at a random time in a
|
||||
(geometrically) expanding interval constrained by minimum and maximum
|
||||
limits.
|
||||
"""
|
||||
def __init__(self, min=0, multiplier=1, max=tenacity._utils.MAX_WAIT,
|
||||
exp_base=2):
|
||||
super(wait_random_exponential, self).__init__(multiplier=multiplier,
|
||||
max=(max-min),
|
||||
exp_base=exp_base)
|
||||
self._random = tenacity.wait_random(min=min, max=(min + multiplier))
|
||||
|
||||
def __call__(self, previous_attempt_number, delay_since_first_attempt):
|
||||
jitter = super(wait_random_exponential,
|
||||
self).__call__(previous_attempt_number,
|
||||
delay_since_first_attempt)
|
||||
self._random.wait_random_max = self._random.wait_random_min + jitter
|
||||
return self._random(previous_attempt_number, delay_since_first_attempt)
|
||||
|
||||
|
||||
def sync(cnxt, entity_id, current_traversal, is_update, propagate,
|
||||
predecessors, new_data):
|
||||
# Retry waits up to 60 seconds at most, with exponentially increasing
|
||||
# amounts of jitter per resource still outstanding
|
||||
wait_strategy = wait_random_exponential(max=60)
|
||||
wait_strategy = tenacity.wait_random_exponential(max=60)
|
||||
|
||||
def init_jitter(existing_input_data):
|
||||
nconflicts = max(0, len(predecessors) - len(existing_input_data) - 1)
|
||||
|
|
Loading…
Reference in New Issue