Skip to content

Commit 741f0ea

Browse files
committed
switch from 'retrying' to 'tenacity'
1 parent bbf8466 commit 741f0ea

25 files changed

+3290
-278
lines changed

news/tenacity.vendor.rst

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Switch from retrying to tenacity
2+

src/pip/_internal/utils/filesystem.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
from contextlib import contextmanager
99
from tempfile import NamedTemporaryFile
1010

11-
# NOTE: retrying is not annotated in typeshed as on 2017-07-17, which is
12-
# why we ignore the type on this import.
13-
from pip._vendor.retrying import retry # type: ignore
11+
from pip._vendor.tenacity import retry, stop_after_delay, wait_fixed
1412

1513
from pip._internal.utils.compat import get_path_uid
1614
from pip._internal.utils.misc import format_size
@@ -104,7 +102,7 @@ def adjacent_tmp_file(path, **kwargs):
104102
os.fsync(result.fileno())
105103

106104

107-
_replace_retry = retry(stop_max_delay=1000, wait_fixed=250)
105+
_replace_retry = retry(reraise=True, stop=stop_after_delay(1), wait=wait_fixed(0.25))
108106

109107
replace = _replace_retry(os.replace)
110108

src/pip/_internal/utils/misc.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
from itertools import filterfalse, tee, zip_longest
1919

2020
from pip._vendor import pkg_resources
21-
22-
# NOTE: retrying is not annotated in typeshed as on 2017-07-17, which is
23-
# why we ignore the type on this import.
24-
from pip._vendor.retrying import retry # type: ignore
21+
from pip._vendor.tenacity import retry, stop_after_delay, wait_fixed
2522

2623
from pip import __version__
2724
from pip._internal.exceptions import CommandError
@@ -122,7 +119,8 @@ def get_prog():
122119

123120

124121
# Retry every half second for up to 3 seconds
125-
@retry(stop_max_delay=3000, wait_fixed=500)
122+
# Tenacity raises RetryError by default, explictly raise the original exception
123+
@retry(reraise=True, stop=stop_after_delay(3), wait=wait_fixed(0.5))
126124
def rmtree(dir, ignore_errors=False):
127125
# type: (AnyStr, bool) -> None
128126
shutil.rmtree(dir, ignore_errors=ignore_errors,

src/pip/_vendor/retrying.py

-267
This file was deleted.

src/pip/_vendor/retrying.pyi

-1
This file was deleted.

src/pip/_vendor/tenacity.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from tenacity import *
File renamed without changes.

0 commit comments

Comments
 (0)