File tree Expand file tree Collapse file tree
vortex-test/compat-gen/scripts Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232import subprocess
3333import sys
3434import tempfile
35+ import time
3536from concurrent .futures import ThreadPoolExecutor , as_completed
3637from datetime import UTC , datetime
3738from pathlib import Path
38- from urllib .error import HTTPError
39+ from urllib .error import HTTPError , URLError
3940from urllib .request import urlopen
4041
4142import jsonschema
@@ -165,13 +166,19 @@ def __init__(self, bucket: str):
165166
166167 def read (self , key : str ) -> bytes | None :
167168 url = f"{ self .https_base } /{ key } "
168- try :
169- with urlopen (url ) as resp :
170- return resp .read ()
171- except HTTPError as e :
172- if e .code in (403 , 404 ):
173- return None
174- raise
169+ for attempt in range (3 ):
170+ try :
171+ with urlopen (url , timeout = 10 ) as resp :
172+ return resp .read ()
173+ except HTTPError as e :
174+ if e .code in (403 , 404 ):
175+ return None
176+ raise
177+ except (URLError , ConnectionError , TimeoutError ):
178+ if attempt < 2 :
179+ time .sleep (1 * (attempt + 1 ))
180+ continue
181+ raise
175182
176183 def write (self , key : str , data : bytes ) -> None :
177184 with tempfile .NamedTemporaryFile (delete = False ) as f :
You can’t perform that action at this time.
0 commit comments