Skip to content

Commit

Permalink
Added urllib3 < 2.X compatibility for the Retry object
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc-Antoine Hinse committed Oct 21, 2024
1 parent 4c583f3 commit cef30e2
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions flareio/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cef30e2

Please sign in to comment.