Update tenacity version and usage

Some tenacity apis now get a single retry_state parameter which contain
all the previous information.

Change-Id: I8c83c21fe424bd6884a8e61893f1bda22dc7787b
This commit is contained in:
Adit Sarfaty 2019-07-22 14:33:35 +03:00
parent eee5406118
commit 7cdfb5175b
3 changed files with 12 additions and 10 deletions

View File

@ -25,7 +25,7 @@ six==1.10.0
sphinx==1.6.5
stestr==1.0.0
tempest==17.1.0
tenacity==4.9.0
tenacity==5.0.1
testresources==2.0.0
testtools==2.2.0
testscenarios==0.4

View File

@ -7,7 +7,7 @@ pbr>=4.0.0 # Apache-2.0
decorator>=4.3.0 # BSD
eventlet>=0.24.1 # MIT
netaddr>=0.7.18 # BSD
tenacity>=4.9.0 # Apache-2.0
tenacity>=5.0.1 # Apache-2.0
six>=1.10.0 # MIT
oslo.i18n>=3.15.3 # Apache-2.0
oslo.log>=3.36.0 # Apache-2.0

View File

@ -128,12 +128,14 @@ def update_v3_tags(current_tags, tags_update):
return tags
def _log_before_retry(func, trial_number):
def _log_before_retry(retry_state):
"""Before call strategy that logs to some logger the attempt."""
if trial_number > 1:
if retry_state.attempt_number > 1:
LOG.warning("Retrying call to '%(func)s' for the %(num)s time",
{'func': tenacity_utils.get_callback_name(func),
'num': tenacity_utils.to_ordinal(trial_number)})
{'func': tenacity_utils.get_callback_name(
retry_state.fn),
'num': tenacity_utils.to_ordinal(
retry_state.attempt_number)})
def _get_args_from_frame(frames, frame_num):
@ -145,7 +147,7 @@ def _get_args_from_frame(frames, frame_num):
return formated_args
def _log_after_retry(func, trial_number, trial_time_taken):
def _log_after_retry(retry_state):
"""After call strategy that logs to some logger the finished attempt."""
# Using inspect to get arguments of the relevant call
frames = inspect.trace()
@ -158,9 +160,9 @@ def _log_after_retry(func, trial_number, trial_time_taken):
LOG.warning("Finished retry of %(func)s for the %(num)s time after "
"%(time)0.3f(s) with args: %(args)s",
{'func': tenacity_utils.get_callback_name(func),
'num': tenacity_utils.to_ordinal(trial_number),
'time': trial_time_taken,
{'func': tenacity_utils.get_callback_name(retry_state.fn),
'num': tenacity_utils.to_ordinal(retry_state.attempt_number),
'time': retry_state.seconds_since_start,
'args': formated_args})