Skip to content

Commit 64ecfc8

Browse files
committed
switch from 'retrying' to 'tenacity'
1 parent 8a949a1 commit 64ecfc8

23 files changed

+1786
-279
lines changed

news/tenacity.vendor.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Switch from retrying to tenacity

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ drop = [
4444
"setuptools",
4545
"pkg_resources/_vendor/",
4646
"pkg_resources/extern/",
47+
# unneeded part for tenacity
48+
"tenacity/tests",
4749
]
4850

4951
[tool.vendoring.typing-stubs]

src/pip/_internal/utils/filesystem.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
from tempfile import NamedTemporaryFile
1010
from typing import Any, BinaryIO, Iterator, List, Union, cast
1111

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

1614
from pip._internal.utils.compat import get_path_uid
1715
from pip._internal.utils.misc import format_size
@@ -101,7 +99,8 @@ def adjacent_tmp_file(path, **kwargs):
10199
os.fsync(result.fileno())
102100

103101

104-
_replace_retry = retry(stop_max_delay=1000, wait_fixed=250)
102+
# Tenacity raises RetryError by default, explictly raise the original exception
103+
_replace_retry = retry(reraise=True, stop=stop_after_delay(1), wait=wait_fixed(0.25))
105104

106105
replace = _replace_retry(os.replace)
107106

src/pip/_internal/utils/misc.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@
3131
)
3232

3333
from pip._vendor.pkg_resources import Distribution
34-
35-
# NOTE: retrying is not annotated in typeshed as on 2017-07-17, which is
36-
# why we ignore the type on this import.
37-
from pip._vendor.retrying import retry # type: ignore
34+
from pip._vendor.tenacity import retry, stop_after_delay, wait_fixed
3835

3936
from pip import __version__
4037
from pip._internal.exceptions import CommandError
@@ -117,7 +114,8 @@ def get_prog():
117114

118115

119116
# Retry every half second for up to 3 seconds
120-
@retry(stop_max_delay=3000, wait_fixed=500)
117+
# Tenacity raises RetryError by default, explictly raise the original exception
118+
@retry(reraise=True, stop=stop_after_delay(3), wait=wait_fixed(0.5))
121119
def rmtree(dir, ignore_errors=False):
122120
# type: (AnyStr, bool) -> None
123121
shutil.rmtree(dir, ignore_errors=ignore_errors,

src/pip/_vendor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ def vendored(modulename):
7575
vendored("pep517")
7676
vendored("pkg_resources")
7777
vendored("progress")
78-
vendored("retrying")
7978
vendored("requests")
8079
vendored("requests.exceptions")
8180
vendored("requests.packages")
@@ -107,6 +106,7 @@ def vendored(modulename):
107106
vendored("requests.packages.urllib3.util.timeout")
108107
vendored("requests.packages.urllib3.util.url")
109108
vendored("resolvelib")
109+
vendored("tenacity")
110110
vendored("toml")
111111
vendored("toml.encoder")
112112
vendored("toml.decoder")

src/pip/_vendor/retrying.py

Lines changed: 0 additions & 267 deletions
This file was deleted.

src/pip/_vendor/retrying.pyi

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/pip/_vendor/tenacity.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from tenacity import *
File renamed without changes.

0 commit comments

Comments
 (0)