Skip to content

Commit

Permalink
adds backoff strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
dapineyro committed Jan 15, 2024
1 parent 0f2c80b commit 91466f7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cloudos/utils/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from urllib3.util import Retry


def retry_requests_get(url, total=4, status_forcelist=[429, 500, 502, 503, 504], **kwargs):
def retry_requests_get(url, total=5, status_forcelist=[429, 500, 502, 503, 504], **kwargs):
"""Wrap normal requests get with an error strategy.
Parameters
Expand All @@ -26,6 +26,7 @@ def retry_requests_get(url, total=4, status_forcelist=[429, 500, 502, 503, 504],
"""
retry_strategy = Retry(
total=total,
backoff_factor=2,
status_forcelist=status_forcelist
)
# Create an HTTP adapter with the retry strategy and mount it to session
Expand All @@ -41,7 +42,7 @@ def retry_requests_get(url, total=4, status_forcelist=[429, 500, 502, 503, 504],
return response


def retry_requests_post(url, total=4, status_forcelist=[429, 500, 502, 503, 504], **kwargs):
def retry_requests_post(url, total=5, status_forcelist=[429, 500, 502, 503, 504], **kwargs):
"""Wrap normal requests post with an error strategy.
Parameters
Expand All @@ -60,6 +61,7 @@ def retry_requests_post(url, total=4, status_forcelist=[429, 500, 502, 503, 504]
"""
retry_strategy = Retry(
total=total,
backoff_factor=2,
status_forcelist=status_forcelist
)
# Create an HTTP adapter with the retry strategy and mount it to session
Expand Down

0 comments on commit 91466f7

Please sign in to comment.