Skip to content

Commit 48443fd

Browse files
committed
pythonbuild: make download retries more robust
We got an uncaught urllib.error.URLError in CI. Let's keep catching more exceptions. And add a missing `else` so the logic is correct.
1 parent 8a08c39 commit 48443fd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pythonbuild/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import sys
1515
import tarfile
1616
import zipfile
17+
import urllib.error
1718
import urllib.request
1819

1920
import yaml
@@ -245,6 +246,10 @@ def download_to_path(url: str, path: pathlib.Path, size: int, sha256: str):
245246
raise
246247
except http.client.HTTPException as e:
247248
print("HTTP exception; retrying: %s" % e)
249+
except urllib.error.URLError as e:
250+
print("urllib error; retrying: %s" % e)
251+
else:
252+
raise Exception("download failed after multiple retries")
248253

249254
tmp.rename(path)
250255
print("successfully downloaded %s" % url)

0 commit comments

Comments
 (0)