Skip to content

Commit

Permalink
Merge pull request #1306 from dmach/connection-retry-on-errors
Browse files Browse the repository at this point in the history
Retry on receiving the following HTTP status codes: 400, 500, 502, 503, 504
  • Loading branch information
dmach authored Apr 27, 2023
2 parents 3f421c8 + e25dc2d commit 6d54931
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions osc/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ def http_request(method: str, url: str, headers=None, data=None, file=None):
pool_kwargs["retries"] = urllib3.Retry(
total=int(conf.config["http_retries"]),
backoff_factor=2,
status_forcelist=(
400, # Bad Request; retry on 400: service in progress
500, # Internal Server Error
502, # Bad Gateway
503, # Service Unavailable
504, # Gateway Timeout
),
# don't raise because we want an actual response rather than a MaxRetryError with "too many <status_code> error responses" message
raise_on_status=False,
**retries_kwargs,
)

Expand Down

0 comments on commit 6d54931

Please sign in to comment.