Skip to content

Commit

Permalink
correctly handle server errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ndharasz committed Oct 11, 2024
1 parent 0bddc6d commit 63c8126
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def retry_request_with_backoff(
retries: int = 10,
delay_base: float = 1.5,
delay_exp: float = 1.5,
retry_on_status_codes: list[int] = [503],
debug: bool = False,
):
delay_base = max(1.1, delay_base)
Expand All @@ -110,9 +109,9 @@ def retry_request_with_backoff(
time.sleep(curr_delay)
curr_delay **= random.uniform(1, delay_exp)
continue
if response.status_code in retry_on_status_codes:
if response.status_code >= 500:
if debug:
logging.debug(f"Recieved status {response.status_code}. Retrying...")
logging.debug(f"Encountered Server Error. Retrying...")
time.sleep(curr_delay)
curr_delay **= random.uniform(1, delay_exp)
elif response.status_code != 200:
Expand Down

0 comments on commit 63c8126

Please sign in to comment.