rustPlatform.fetchCargoVendor: retry fetching tarballs (#357262)

authored by

Jörg Thalheim and committed by
GitHub
bf20efd0 a4d71153

+11 -1
+11 -1
pkgs/build-support/rust/fetch-cargo-vendor-util.py
··· 11 11 from typing import Any, TypedDict, cast 12 12 13 13 import requests 14 + from requests.adapters import HTTPAdapter, Retry 14 15 15 16 eprint = functools.partial(print, file=sys.stderr) 16 17 ··· 21 22 22 23 23 24 def download_file_with_checksum(url: str, destination_path: Path) -> str: 25 + retries = Retry( 26 + total=5, 27 + backoff_factor=0.5, 28 + status_forcelist=[500, 502, 503, 504] 29 + ) 30 + session = requests.Session() 31 + session.mount('http://', HTTPAdapter(max_retries=retries)) 32 + session.mount('https://', HTTPAdapter(max_retries=retries)) 33 + 24 34 sha256_hash = hashlib.sha256() 25 - with requests.get(url, stream=True) as response: 35 + with session.get(url, stream=True) as response: 26 36 if not response.ok: 27 37 raise Exception(f"Failed to fetch file from {url}. Status code: {response.status_code}") 28 38 with open(destination_path, "wb") as file: