diff --git a/requirements.txt b/requirements.txt --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ # Add here external Python modules dependencies, one per line. Module names # should match https://pypi.python.org/pypi names. For the full spec or # dependency lines, see https://pip.readthedocs.org/en/1.1/requirements.html + +tenacity >= 6.2 diff --git a/swh/objstorage/replayer/replay.py b/swh/objstorage/replayer/replay.py --- a/swh/objstorage/replayer/replay.py +++ b/swh/objstorage/replayer/replay.py @@ -1,4 +1,4 @@ -# Copyright (C) 2019-2020 The Software Heritage developers +# Copyright (C) 2019-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -96,13 +96,9 @@ def log_replay_retry(retry_state, sleep=None, last_result=None): """Log a retry of the content replayer""" - try: - exc = retry_state.outcome.exception() - attempt_number = retry_state.attempt_number - except AttributeError: - # tenacity < 5.0 - exc = last_result.exception() - attempt_number = retry_state.statistics["attempt_number"] + + exc = retry_state.outcome.exception() + attempt_number = retry_state.attempt_number logger.debug( "Retry operation %(operation)s on %(obj_id)s: %(exc)s", @@ -117,11 +113,8 @@ def log_replay_error(retry_state): """Log a replay error to sentry""" - try: - exc = retry_state.outcome.exception() - except AttributeError: - # tenacity < 5.0 - exc = retry_state.exception() + + exc = retry_state.outcome.exception() with push_scope() as scope: scope.set_tag("operation", exc.operation)