Skip to content

Commit

Permalink
[hailtop] Don't log rate limit errors (#14605)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvittal committed Jul 9, 2024
1 parent ab5c1ff commit 366e708
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions hail/python/hailtop/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,18 @@ def is_transient_error(e: BaseException) -> bool:
return False


def is_rate_limit_error(e: BaseException) -> bool:
import hailtop.httpx # pylint: disable=import-outside-toplevel,cyclic-import

if isinstance(e, aiohttp.ClientResponseError) and e.status == 429:
return True
if isinstance(e, hailtop.httpx.ClientResponseError) and (
e.status == 429 or e.status == 403 and 'rateLimitExceeded' in e.body
):
return True
return False


def is_delayed_warning_error(e: BaseException) -> bool:
if isinstance(e, aiohttp.ClientResponseError) and e.status in (503, 429):
# 503 service unavailable
Expand Down Expand Up @@ -791,6 +803,7 @@ async def retry_transient_errors_with_debug_string(
) -> T:
start_time = time_msecs()
tries = 0

while True:
try:
return await f(*args, **kwargs)
Expand All @@ -805,6 +818,8 @@ async def retry_transient_errors_with_debug_string(
f'{5 - tries} more times. Do not be alarmed. (next delay: '
f'{delay}s). The most recent error was {type(e)} {e}. {debug_string}'
)
elif is_rate_limit_error(e):
pass
elif not is_transient_error(e):
raise
else:
Expand Down

0 comments on commit 366e708

Please sign in to comment.