Skip to content

Commit

Permalink
switch from 'retrying' to 'tenacity'
Browse files Browse the repository at this point in the history
  • Loading branch information
cjc7373 committed Feb 21, 2021
1 parent 8a949a1 commit 64ecfc8
Show file tree
Hide file tree
Showing 23 changed files with 1,786 additions and 279 deletions.
1 change: 1 addition & 0 deletions news/tenacity.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Switch from retrying to tenacity
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ drop = [
"setuptools",
"pkg_resources/_vendor/",
"pkg_resources/extern/",
# unneeded part for tenacity
"tenacity/tests",
]

[tool.vendoring.typing-stubs]
Expand Down
7 changes: 3 additions & 4 deletions src/pip/_internal/utils/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
from tempfile import NamedTemporaryFile
from typing import Any, BinaryIO, Iterator, List, Union, cast

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

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


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

replace = _replace_retry(os.replace)

Expand Down
8 changes: 3 additions & 5 deletions src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
)

from pip._vendor.pkg_resources import Distribution

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

from pip import __version__
from pip._internal.exceptions import CommandError
Expand Down Expand Up @@ -117,7 +114,8 @@ def get_prog():


# Retry every half second for up to 3 seconds
@retry(stop_max_delay=3000, wait_fixed=500)
# Tenacity raises RetryError by default, explictly raise the original exception
@retry(reraise=True, stop=stop_after_delay(3), wait=wait_fixed(0.5))
def rmtree(dir, ignore_errors=False):
# type: (AnyStr, bool) -> None
shutil.rmtree(dir, ignore_errors=ignore_errors,
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_vendor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def vendored(modulename):
vendored("pep517")
vendored("pkg_resources")
vendored("progress")
vendored("retrying")
vendored("requests")
vendored("requests.exceptions")
vendored("requests.packages")
Expand Down Expand Up @@ -107,6 +106,7 @@ def vendored(modulename):
vendored("requests.packages.urllib3.util.timeout")
vendored("requests.packages.urllib3.util.url")
vendored("resolvelib")
vendored("tenacity")
vendored("toml")
vendored("toml.encoder")
vendored("toml.decoder")
Expand Down
267 changes: 0 additions & 267 deletions src/pip/_vendor/retrying.py

This file was deleted.

1 change: 0 additions & 1 deletion src/pip/_vendor/retrying.pyi

This file was deleted.

1 change: 1 addition & 0 deletions src/pip/_vendor/tenacity.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from tenacity import *
File renamed without changes.
Loading

0 comments on commit 64ecfc8

Please sign in to comment.