diff --git a/launchable/utils/env_keys.py b/launchable/utils/env_keys.py index ed1980a7f..a45af6cc0 100644 --- a/launchable/utils/env_keys.py +++ b/launchable/utils/env_keys.py @@ -3,3 +3,4 @@ ORGANIZATION_KEY = "LAUNCHABLE_ORGANIZATION" WORKSPACE_KEY = "LAUNCHABLE_WORKSPACE" BASE_URL_KEY = "LAUNCHABLE_BASE_URL" +SKIP_TIMEOUT_RETRY = "LAUNCHABLE_SKIP_TIMEOUT_RETRY" diff --git a/launchable/utils/http_client.py b/launchable/utils/http_client.py index c5d3eeca9..0044ecb99 100644 --- a/launchable/utils/http_client.py +++ b/launchable/utils/http_client.py @@ -14,7 +14,7 @@ from ..app import Application from .authentication import authentication_headers -from .env_keys import BASE_URL_KEY +from .env_keys import BASE_URL_KEY, SKIP_TIMEOUT_RETRY from .gzipgen import compress as gzipgen_compress from .logger import AUDIT_LOG_FORMAT, Logger @@ -24,6 +24,8 @@ DEFAULT_TIMEOUT: Tuple[int, int] = (5, 60) DEFAULT_GET_TIMEOUT: Tuple[int, int] = (5, 15) +MAX_RETRIES = 3 + def get_base_url(): return os.getenv(BASE_URL_KEY) or DEFAULT_BASE_URL @@ -49,8 +51,12 @@ def __init__(self, base_url: str = "", session: Optional[Session] = None, self.skip_cert_verification = bool(app and app.skip_cert_verification) if session is None: + read = MAX_RETRIES + if os.getenv(SKIP_TIMEOUT_RETRY): + read = 0 strategy = Retry( - total=3, + total=MAX_RETRIES, + read=read, allowed_methods=["GET", "PUT", "PATCH", "DELETE"], status_forcelist=[429, 500, 502, 503, 504], backoff_factor=2