Skip to content

Commit

Permalink
never sleep for more than 1 hour
Browse files Browse the repository at this point in the history
Signed-off-by: Will Murphy <[email protected]>
  • Loading branch information
willmurphyscode committed Oct 30, 2023
1 parent c115823 commit 11d11e2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/vunnel/providers/github/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,13 @@ def get_query(token, query, timeout=125, api_url="https://api.github.com/graphql
current_time = int(time.time())
sleep_time = reset_time - current_time
# note that the rate limit resets 1x / hour, so this could be a long time
logger.info(f"sleeping for {sleep_time} seconds to allow GitHub rate limit to reset")
time.sleep(sleep_time)
if sleep_time > 1 and sleep_time < 3600: # never sleep for more than 1 hour
logger.info(f"sleeping for {sleep_time} seconds to allow GitHub rate limit to reset")
time.sleep(sleep_time)
elif sleep_time > 3600:
raise Exception(
f"github rate limit exhaused and not expected to reset for {sleep_time} seconds. Try again later.",
)
response.raise_for_status()
if response.status_code == 200:
return response.json()
Expand Down

0 comments on commit 11d11e2

Please sign in to comment.