Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions PCbuild/get_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
import pathlib
import sys
import time
import urllib.error
import urllib.request
import zipfile
from urllib.request import urlretrieve


def retrieve_with_retries(download_location, output_path, reporthook,
max_retries=7):
"""Download a file with exponential backoff retry and save to disk."""
for attempt in range(max_retries + 1):
try:
resp = urlretrieve(
resp = urllib.request.urlretrieve(
download_location,
output_path,
reporthook=reporthook,
)
except ConnectionError as ex:
except (urllib.error.URLError, ConnectionError) as ex:
if attempt == max_retries:
msg = f"Download from {download_location} failed."
raise OSError(msg) from ex
Expand Down
2 changes: 1 addition & 1 deletion Tools/build/generate_sbom.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def download_with_retries(download_location: str,
for attempt in range(max_retries + 1):
try:
resp = urllib.request.urlopen(download_location)
except urllib.error.URLError as ex:
except (urllib.error.URLError, ConnectionError) as ex:
if attempt == max_retries:
msg = f"Download from {download_location} failed."
raise OSError(msg) from ex
Expand Down
Loading