Skip to content

Commit 182c6da

Browse files
committed
fix
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent 61bc044 commit 182c6da

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

vortex-test/compat-gen/scripts/compat.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@
3232
import subprocess
3333
import sys
3434
import tempfile
35+
import time
3536
from concurrent.futures import ThreadPoolExecutor, as_completed
3637
from datetime import UTC, datetime
3738
from pathlib import Path
38-
from urllib.error import HTTPError
39+
from urllib.error import HTTPError, URLError
3940
from urllib.request import urlopen
4041

4142
import 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:

0 commit comments

Comments
 (0)