Skip to content

Commit 4f63ce4

Browse files
authored
Merge pull request #992 from launchableinc/AIENG-73
[AIENG-73] Disable retry when ReadTimeout occurs
2 parents 34704db + 9875b30 commit 4f63ce4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

launchable/utils/env_keys.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
ORGANIZATION_KEY = "LAUNCHABLE_ORGANIZATION"
44
WORKSPACE_KEY = "LAUNCHABLE_WORKSPACE"
55
BASE_URL_KEY = "LAUNCHABLE_BASE_URL"
6+
SKIP_TIMEOUT_RETRY = "LAUNCHABLE_SKIP_TIMEOUT_RETRY"

launchable/utils/http_client.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from ..app import Application
1616
from .authentication import authentication_headers
17-
from .env_keys import BASE_URL_KEY
17+
from .env_keys import BASE_URL_KEY, SKIP_TIMEOUT_RETRY
1818
from .gzipgen import compress as gzipgen_compress
1919
from .logger import AUDIT_LOG_FORMAT, Logger
2020

@@ -24,6 +24,8 @@
2424
DEFAULT_TIMEOUT: Tuple[int, int] = (5, 60)
2525
DEFAULT_GET_TIMEOUT: Tuple[int, int] = (5, 15)
2626

27+
MAX_RETRIES = 3
28+
2729

2830
def get_base_url():
2931
return os.getenv(BASE_URL_KEY) or DEFAULT_BASE_URL
@@ -49,8 +51,12 @@ def __init__(self, base_url: str = "", session: Optional[Session] = None,
4951
self.skip_cert_verification = bool(app and app.skip_cert_verification)
5052

5153
if session is None:
54+
read = MAX_RETRIES
55+
if os.getenv(SKIP_TIMEOUT_RETRY):
56+
read = 0
5257
strategy = Retry(
53-
total=3,
58+
total=MAX_RETRIES,
59+
read=read,
5460
allowed_methods=["GET", "PUT", "PATCH", "DELETE"],
5561
status_forcelist=[429, 500, 502, 503, 504],
5662
backoff_factor=2

0 commit comments

Comments
 (0)