88from click import Context
99from requests import Session
1010from requests .adapters import HTTPAdapter
11- from urllib3 .util .retry import Retry
11+ from requests . packages . urllib3 .util .retry import Retry # type: ignore
1212
1313from launchable .version import __version__
1414
1515from ..app import Application
1616from .authentication import authentication_headers
17- from .env_keys import BASE_URL_KEY
17+ from .env_keys import BASE_URL_KEY , SKIP_TIMEOUT_RETRY
1818from .gzipgen import compress as gzipgen_compress
1919from .logger import AUDIT_LOG_FORMAT , Logger
2020
@@ -31,18 +31,6 @@ def get_base_url():
3131 return os .getenv (BASE_URL_KEY ) or DEFAULT_BASE_URL
3232
3333
34- def default_retry_strategy ():
35- return Retry (
36- total = MAX_RETRIES ,
37- # When Launchable server is unstable, ReadTimeout can occur.
38- # To prevent the execution from slowing down, we disable retrying the request in this case.
39- read = 0 ,
40- allowed_methods = ["GET" , "PUT" , "PATCH" , "DELETE" ],
41- status_forcelist = [429 , 500 , 502 , 503 , 504 ],
42- backoff_factor = 2
43- )
44-
45-
4634class DryRunResponse :
4735 def __init__ (self , status_code , payload ):
4836 self .status_code = status_code
@@ -63,7 +51,17 @@ def __init__(self, base_url: str = "", session: Optional[Session] = None,
6351 self .skip_cert_verification = bool (app and app .skip_cert_verification )
6452
6553 if session is None :
66- strategy = default_retry_strategy ()
54+ read = MAX_RETRIES
55+ if os .getenv (SKIP_TIMEOUT_RETRY ):
56+ read = 0
57+ strategy = Retry (
58+ total = MAX_RETRIES ,
59+ read = read ,
60+ allowed_methods = ["GET" , "PUT" , "PATCH" , "DELETE" ],
61+ status_forcelist = [429 , 500 , 502 , 503 , 504 ],
62+ backoff_factor = 2
63+ )
64+
6765 adapter = HTTPAdapter (max_retries = strategy )
6866 s = Session ()
6967 s .mount ("http://" , adapter )
0 commit comments