Skip to content

Commit 2796bd1

Browse files
committed
Catch both URLError and ConnectionError in retries
1 parent 0f866cb commit 2796bd1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

PCbuild/get_external.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pathlib
66
import sys
77
import time
8+
import urllib.error
89
import zipfile
910
from urllib.request import urlretrieve
1011

@@ -19,7 +20,7 @@ def retrieve_with_retries(download_location, output_path, reporthook,
1920
output_path,
2021
reporthook=reporthook,
2122
)
22-
except ConnectionError as ex:
23+
except (urllib.error.URLError, ConnectionError) as ex:
2324
if attempt == max_retries:
2425
msg = f"Download from {download_location} failed."
2526
raise OSError(msg) from ex

Tools/build/generate_sbom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def download_with_retries(download_location: str,
172172
for attempt in range(max_retries + 1):
173173
try:
174174
resp = urllib.request.urlopen(download_location)
175-
except urllib.error.URLError as ex:
175+
except (urllib.error.URLError, ConnectionError) as ex:
176176
if attempt == max_retries:
177177
msg = f"Download from {download_location} failed."
178178
raise OSError(msg) from ex

0 commit comments

Comments
 (0)