Skip to content

Commit

Permalink
Update main.py to ensure x-ratelimit is in headers
Browse files Browse the repository at this point in the history
  • Loading branch information
alexboden authored Nov 29, 2024
1 parent e365e9a commit 4f8b55e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ def get_gh_api(url, token, etag=None):
headers['If-None-Match'] = etag

response = requests.get(url, headers=headers)
if int(response.headers['X-RateLimit-Remaining']) % 100 == 0:
logger.info(f"Rate Limit Remaining: {response.headers['X-RateLimit-Remaining']}")
if 'X-RateLimit-Remaining' in response.headers:
if int(response.headers['X-RateLimit-Remaining']) % 100 == 0:
logger.info(f"Rate Limit Remaining: {response.headers['X-RateLimit-Remaining']}")

if response.status_code == 304:
return None, etag
elif response.status_code == 200:
Expand Down

0 comments on commit 4f8b55e

Please sign in to comment.