@@ -630,19 +630,26 @@ def raw_http_request(self, url: str, data: bytes | None = None):
630630 request = urllib .request .Request (url = url , headers = headers , data = data )
631631
632632 retry_count = 0
633- while retry_count <= maximum_urlopen_retries :
634- retry_count += 1
633+ while True :
635634 try :
636635 # The rate limit API is not subject to rate limiting
637636 if url .startswith ("https://api.github.com" ) and not url .startswith ("https://api.github.com/rate_limit" ):
638637 self .handle_rate_limiting ()
639638 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" ))
643651
644- # Maximum retries reached without successfully opening URL
645- raise TimeoutError ("Maximum number of URL load retries exceeded" )
652+ raise exception
646653
647654 def handle_rate_limiting (self ) -> None :
648655 """Check whether the GitHub API request limit has been reached.
@@ -664,7 +671,7 @@ def handle_rate_limiting(self) -> None:
664671 sys .exit (0 )
665672
666673
667- def determine_urlopen_retry (exception ) -> bool :
674+ def determine_urlopen_retry (exception : urllib . error . HTTPError ) -> bool :
668675 """Determine whether the exception warrants another attempt at opening the URL.
669676 If so, delay then return True. Otherwise, return False.
670677
0 commit comments