diff --git a/lower-constraints.txt b/lower-constraints.txt index 490e2b32..5475cf29 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -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 diff --git a/requirements.txt b/requirements.txt index fa0911e4..175d63a7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/vmware_nsxlib/v3/utils.py b/vmware_nsxlib/v3/utils.py index 32af86f9..9eabbbbd 100644 --- a/vmware_nsxlib/v3/utils.py +++ b/vmware_nsxlib/v3/utils.py @@ -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})