diff --git a/flareio/api_client.py b/flareio/api_client.py index 290e099..263d994 100644 --- a/flareio/api_client.py +++ b/flareio/api_client.py @@ -47,18 +47,21 @@ def _create_session() -> requests.Session: ), ) + retry = Retry( + total=5, + backoff_factor=2, + status_forcelist=[429, 502, 503, 504], + allowed_methods={"GET", "POST"}, + ) + + # Support for urllib3 < 2.X + if hasattr(Retry, "backoff_max"): + retry.backoff_max = 15 + # Enable retries session.mount( "https://", - HTTPAdapter( - max_retries=Retry( - total=5, - backoff_factor=2, - status_forcelist=[429, 502, 503, 504], - allowed_methods={"GET", "POST"}, - backoff_max=15, - ) - ), + HTTPAdapter(max_retries=retry), ) return session