File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 2222TIMEOUT = 3
2323INITIAL_RATELIMIT = 5000
2424LRU_CACHE_SIZE = 6000
25+ NORMALIZE_REPO_CACHE_SIZE = 128
26+ NORMALIZE_REPO_CACHE_EXPIRY_SECONDS = 600
2527
2628_api_initialized = False
2729
@@ -379,7 +381,15 @@ def get_master_repo(
379381 r = r ["parent" ]
380382
381383
384+ normalize_repo_cache = LRUCache (NORMALIZE_REPO_CACHE_SIZE )
385+
386+
382387def normalize_repo (repo ):
388+ global normalize_repo_cache
389+ if repo in normalize_repo_cache :
390+ cache = normalize_repo_cache [repo ]
391+ if time .time () - cache [0 ] < NORMALIZE_REPO_CACHE_EXPIRY_SECONDS :
392+ return cache [1 ]
383393 r = call (
384394 repo ,
385395 _method = "HEAD" ,
@@ -388,6 +398,7 @@ def normalize_repo(repo):
388398 _ignore_rate_limit = True ,
389399 )
390400 r .raise_for_status ()
401+ normalize_repo_cache [repo ] = (time .time (), r .url )
391402 return r .url
392403
393404
Original file line number Diff line number Diff line change @@ -1727,7 +1727,11 @@ def allow_github_api_calls():
17271727 return False
17281728 return True
17291729
1730- user , repo = gh .parse_repo (gh .normalize_repo (tests_repo (run )))
1730+ try :
1731+ user , repo = gh .parse_repo (gh .normalize_repo (tests_repo (run )))
1732+ except Exception as e :
1733+ user , repo = gh .parse_repo (tests_repo (run ))
1734+ print (f"Unable to normalize_repo: { str (e )} " )
17311735
17321736 anchor_url = gh .compare_branches_url (
17331737 user1 = "official-stockfish" ,
You can’t perform that action at this time.
0 commit comments