Skip to content

Commit

Permalink
Handle secondary rate limits that show up as "plain exceptions"
Browse files Browse the repository at this point in the history
We previously handled secondary rate limit errors, however, it turns
out that we aren't getting the exception type that we were seeing then
for all secondary rate limits.

This PR updates to handle the generic "GitHubException" that PyGitHub
uses. If we get the more generic error and it contains a secondary
rate limit message from GitHub, we will handle with our usual "wait
and try again" strategy.
  • Loading branch information
SeanTAllen committed Oct 16, 2024
1 parent b13f9b4 commit 580b264
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from git.exc import GitCommandError
from github import Github
from github.GithubException import RateLimitExceededException
from github.GithubException import GithubException

CHANGELOG_LABELS = ['changelog - added',
'changelog - changed',
Expand Down Expand Up @@ -67,6 +68,20 @@
else:
print(ERROR + "Search failed again. Giving up." + ENDC)
raise
except GithubException as e:
if "You have exceeded a secondary rate limit" in e.data['message']:
search_failures += 1
if search_failures <= 5:
print(NOTICE
+ "Search failed due to secondary rate limit exceeded. "
+ "Sleeping and trying again."
+ ENDC)
time.sleep(30)
else:
print(ERROR + "Search failed again. Giving up." + ENDC)
raise
else:
raise

repo = github.get_repo(repo_name)
pull_request = repo.get_pull(pr_id)
Expand Down

0 comments on commit 580b264

Please sign in to comment.