diff options
| author | JJ Liebig <jonathan.liebig@gmail.com> | 2026-09-14 22:41:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-14 22:41:54 +0200 |
| commit | e61206cc9d4e13688d2baed4a866c2bcd6ec0736 (patch) | |
| tree | 9fbab1165d08f5b34598486d8c24b2714f4791ce /scripts/package_windows_conpty.py | |
| parent | f867dabbe676255e75a512df343617bd4ca45d0d (diff) | |
test: deflake recent CI failures (#4139)
Diffstat (limited to 'scripts/package_windows_conpty.py')
| -rw-r--r-- | scripts/package_windows_conpty.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/scripts/package_windows_conpty.py b/scripts/package_windows_conpty.py index 2fc51a1e..3c63312e 100644 --- a/scripts/package_windows_conpty.py +++ b/scripts/package_windows_conpty.py @@ -7,6 +7,8 @@ import json import shutil import struct import tempfile +import time +import urllib.error import urllib.request import xml.etree.ElementTree as ET import zipfile @@ -74,10 +76,18 @@ def validate_nuspec(archive: zipfile.ZipFile, package: dict[str, Any]) -> None: def acquire_package(package: dict[str, Any], package_path: Path) -> None: package_path.parent.mkdir(parents=True, exist_ok=True) if not package_path.exists(): - with urllib.request.urlopen( - package["url"], timeout=DOWNLOAD_TIMEOUT_SECONDS - ) as response, package_path.open("wb") as output: - shutil.copyfileobj(response, output) + for attempt in range(3): + try: + with urllib.request.urlopen( + package["url"], timeout=DOWNLOAD_TIMEOUT_SECONDS + ) as response, package_path.open("wb") as output: + shutil.copyfileobj(response, output) + break + except urllib.error.HTTPError as error: + if error.code < 500 or attempt == 2: + raise + error.close() + time.sleep(2**attempt) actual = sha256_file(package_path) if actual != package["sha256"]: raise ValueError( |
