Update tenacity version and usage
Some tenacity apis now get a single retry_state parameter which contain all the previous information. Change-Id: I3e34949dfb9a72ef30706f91beef079894d26201
This commit is contained in:
parent
0a256d2942
commit
883816713d
@ -38,7 +38,7 @@ SQLAlchemy==1.2.0
|
|||||||
sphinx==1.6.5
|
sphinx==1.6.5
|
||||||
stestr==1.0.0
|
stestr==1.0.0
|
||||||
stevedore==1.20.0
|
stevedore==1.20.0
|
||||||
tenacity==4.9.0
|
tenacity==5.0.1
|
||||||
testtools==2.2.0
|
testtools==2.2.0
|
||||||
tooz==1.58.0
|
tooz==1.58.0
|
||||||
vmware-nsxlib==13.1.0
|
vmware-nsxlib==13.1.0
|
||||||
|
@ -7,7 +7,7 @@ eventlet>=0.24.1 # MIT
|
|||||||
httplib2>=0.9.1 # MIT
|
httplib2>=0.9.1 # MIT
|
||||||
requests>=2.14.2 # Apache-2.0
|
requests>=2.14.2 # Apache-2.0
|
||||||
netaddr>=0.7.18 # BSD
|
netaddr>=0.7.18 # BSD
|
||||||
tenacity>=4.9.0 # Apache-2.0
|
tenacity>=5.0.1 # Apache-2.0
|
||||||
SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.2.0 # MIT
|
SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.2.0 # MIT
|
||||||
six>=1.11.0 # MIT
|
six>=1.11.0 # MIT
|
||||||
stevedore>=1.20.0 # Apache-2.0
|
stevedore>=1.20.0 # Apache-2.0
|
||||||
|
@ -164,12 +164,14 @@ def _get_bad_request_error_code(e):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _log_before_retry(func, trial_number):
|
def _log_before_retry(retry_state):
|
||||||
"""Before call strategy that logs to some logger the attempt."""
|
"""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",
|
LOG.warning("Retrying call to '%(func)s' for the %(num)s time",
|
||||||
{'func': tenacity_utils.get_callback_name(func),
|
{'func': tenacity_utils.get_callback_name(
|
||||||
'num': tenacity_utils.to_ordinal(trial_number)})
|
retry_state.fn),
|
||||||
|
'num': tenacity_utils.to_ordinal(
|
||||||
|
retry_state.attempt_number)})
|
||||||
|
|
||||||
|
|
||||||
def _get_args_from_frame(frames, frame_num):
|
def _get_args_from_frame(frames, frame_num):
|
||||||
@ -183,19 +185,22 @@ def _get_args_from_frame(frames, frame_num):
|
|||||||
return formated_args
|
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."""
|
"""After call strategy that logs to some logger the finished attempt."""
|
||||||
# Using inspect to get arguments of the relevant call
|
# Using inspect to get arguments of the relevant call
|
||||||
frames = inspect.trace()
|
frames = inspect.trace()
|
||||||
formated_args = _get_args_from_frame(frames, 1)
|
# Look at frame #2 first because of the internal functions _do_X
|
||||||
|
formated_args = _get_args_from_frame(frames, 2)
|
||||||
|
if not formated_args:
|
||||||
|
formated_args = _get_args_from_frame(frames, 1)
|
||||||
if not formated_args:
|
if not formated_args:
|
||||||
formated_args = "Unknown"
|
formated_args = "Unknown"
|
||||||
|
|
||||||
LOG.warning("Finished retry of %(func)s for the %(num)s time after "
|
LOG.warning("Finished retry of %(func)s for the %(num)s time after "
|
||||||
"%(time)0.3f(s) with args: %(args)s",
|
"%(time)0.3f(s) with args: %(args)s",
|
||||||
{'func': tenacity_utils.get_callback_name(func),
|
{'func': tenacity_utils.get_callback_name(retry_state.fn),
|
||||||
'num': tenacity_utils.to_ordinal(trial_number),
|
'num': tenacity_utils.to_ordinal(retry_state.attempt_number),
|
||||||
'time': trial_time_taken,
|
'time': retry_state.seconds_since_start,
|
||||||
'args': formated_args})
|
'args': formated_args})
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user