Skip to content

Commit c893998

Browse files
committed
Simplify to exponential backoff
1 parent 209eccc commit c893998

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

PCbuild/get_external.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
import argparse
44
import os
55
import pathlib
6-
import random
76
import sys
87
import time
98
import zipfile
109
from urllib.request import urlretrieve
1110

1211

1312
def retrieve_with_retries(download_location, output_path, reporthook,
14-
max_retries=7, base_delay=2.25, max_jitter=1.0):
13+
max_retries=7):
1514
"""Download a file with exponential backoff retry and save to disk."""
1615
for attempt in range(max_retries):
1716
try:
@@ -24,7 +23,7 @@ def retrieve_with_retries(download_location, output_path, reporthook,
2423
if attempt == max_retries:
2524
msg = f"Download from {download_location} failed."
2625
raise OSError(msg) from ex
27-
time.sleep(base_delay**attempt + random.uniform(0, max_jitter))
26+
time.sleep(2.25**attempt)
2827
else:
2928
return resp
3029

0 commit comments

Comments
 (0)