Commit fba14ba5 by Nejc Habjan Committed by Randy Döring

fix: consistently retry on error codes in publish and install

parent d07dddbc
......@@ -21,6 +21,7 @@ from urllib3 import util
from poetry.__version__ import __version__
from poetry.utils.constants import REQUESTS_TIMEOUT
from poetry.utils.constants import STATUS_FORCELIST
from poetry.utils.patterns import wheel_file_re
......@@ -68,7 +69,7 @@ class Uploader:
connect=5,
total=10,
allowed_methods=["GET"],
status_forcelist=[500, 501, 502, 503],
status_forcelist=STATUS_FORCELIST,
)
return adapters.HTTPAdapter(max_retries=retry)
......
......@@ -24,6 +24,7 @@ from filelock import FileLock
from poetry.config.config import Config
from poetry.exceptions import PoetryException
from poetry.utils.constants import REQUESTS_TIMEOUT
from poetry.utils.constants import STATUS_FORCELIST
from poetry.utils.password_manager import HTTPAuthCredential
from poetry.utils.password_manager import PasswordManager
......@@ -259,7 +260,7 @@ class Authenticator:
if is_last_attempt:
raise e
else:
if resp.status_code not in [502, 503, 504] or is_last_attempt:
if resp.status_code not in STATUS_FORCELIST or is_last_attempt:
if raise_for_status:
resp.raise_for_status()
return resp
......
......@@ -3,3 +3,6 @@ from __future__ import annotations
# Timeout for HTTP requests using the requests library.
REQUESTS_TIMEOUT = 15
# Server response codes to retry requests on.
STATUS_FORCELIST = [500, 501, 502, 503, 504]
......@@ -249,7 +249,8 @@ def test_authenticator_request_raises_exception_when_attempts_exhausted(
(401, 0),
(403, 0),
(404, 0),
(500, 0),
(500, 5),
(501, 5),
(502, 5),
(503, 5),
(504, 5),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment