@@ -630,19 +630,26 @@ def raw_http_request(self, url: str, data: bytes | None = None):
630
630
request = urllib .request .Request (url = url , headers = headers , data = data )
631
631
632
632
retry_count = 0
633
- while retry_count <= maximum_urlopen_retries :
634
- retry_count += 1
633
+ while True :
635
634
try :
636
635
# The rate limit API is not subject to rate limiting
637
636
if url .startswith ("https://api.github.com" ) and not url .startswith ("https://api.github.com/rate_limit" ):
638
637
self .handle_rate_limiting ()
639
638
return urllib .request .urlopen (url = request )
640
- except Exception as exception :
641
- if not determine_urlopen_retry (exception = exception ):
642
- raise exception
639
+ except urllib .error .HTTPError as exception :
640
+ if determine_urlopen_retry (exception = exception ):
641
+ if retry_count < maximum_urlopen_retries :
642
+ retry_count += 1
643
+ continue
644
+ else :
645
+ # Maximum retries reached without successfully opening URL
646
+ print ("Maximum number of URL load retries exceeded" )
647
+
648
+ print (f"::error::{ exception .__class__ .__name__ } : { exception } " )
649
+ for line in exception .fp :
650
+ print (line .decode (encoding = "utf-8" , errors = "ignore" ))
643
651
644
- # Maximum retries reached without successfully opening URL
645
- raise TimeoutError ("Maximum number of URL load retries exceeded" )
652
+ raise exception
646
653
647
654
def handle_rate_limiting (self ) -> None :
648
655
"""Check whether the GitHub API request limit has been reached.
@@ -664,7 +671,7 @@ def handle_rate_limiting(self) -> None:
664
671
sys .exit (0 )
665
672
666
673
667
- def determine_urlopen_retry (exception ) -> bool :
674
+ def determine_urlopen_retry (exception : urllib . error . HTTPError ) -> bool :
668
675
"""Determine whether the exception warrants another attempt at opening the URL.
669
676
If so, delay then return True. Otherwise, return False.
670
677
0 commit comments