Skip to content

Commit

Permalink
Merge pull request #82 from SecurityAndStuff/main
Browse files Browse the repository at this point in the history
Handle rate limit correctly
  • Loading branch information
jboursier-mwb authored May 12, 2023
2 parents 61f68dd + 4f961af commit dcc48b0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ghas_cli/utils/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ def check_rate_limit(response: Any) -> bool:
f"Rate limit reached: {response.headers['x-ratelimit-remaining']}/{response.headers['x-ratelimit-limit']} - {reset_time}"
)

time.sleep(int(response.headers["x-ratelimit-remaining"]))
time_to_wait = int(reset_time.timestamp()) - (time.time())

logging.info(f"Waiting {time_to_wait} seconds before retrying.")
time.sleep(time_to_wait)

return True

if response.status_code == 403:
Expand Down

0 comments on commit dcc48b0

Please sign in to comment.