From dba1b7742bb7e327c472d1cad73b55a9f37406e2 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sun, 28 Jun 2026 23:45:43 +0900 Subject: [PATCH] fix(scanner): fail-fast skip on GitHub rate limit (plain urllib3 Retry) Replace PyGithub's default GithubRetry (which sleeps until rate-limit reset and retries up to 10x) with a plain urllib3 Retry. A rate-limit 403/429 is no longer in status_forcelist, so it raises RateLimitExceededException immediately; renew_stat's except-block catches it and skips. Transient 5xx errors remain retried (D2). [#1-sub-2] --- scanner.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scanner.py b/scanner.py index d5307e74..aff8e385 100644 --- a/scanner.py +++ b/scanner.py @@ -17,6 +17,7 @@ builtin_nodes = set() import sys from urllib.parse import urlparse +from urllib3.util.retry import Retry from github import Github, Auth from pathlib import Path from typing import Set, Dict, Optional @@ -1619,7 +1620,14 @@ if __name__ == "__main__": if not skip_stat_update: auth = Auth.Token(os.environ.get('GITHUB_TOKEN')) - g = Github(auth=auth) + # Use a plain urllib3 Retry (NOT PyGithub's default GithubRetry) so that + # a GitHub rate-limit response (403/429) raises RateLimitExceededException + # IMMEDIATELY instead of sleeping until the rate-limit reset and retrying + # up to 10x. The except-block in renew_stat() then catches it and skips + # (returns None). 403/429 are intentionally NOT in status_forcelist, so + # they fail fast; only transient 5xx errors are retried. + g = Github(auth=auth, retry=Retry(total=2, backoff_factor=0.5, + status_forcelist=[500, 502, 503, 504])) else: g = None