Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions launchable/utils/env_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 8 additions & 2 deletions launchable/utils/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
Loading