Skip to content

Commit 3f9eb55

Browse files
authored
gh-134262: increase retries in Tools/build/generate_sbom.py (#134558)
1 parent 9b5e800 commit 3f9eb55

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Tools/build/generate_sbom.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import hashlib
55
import json
66
import os
7+
import random
78
import re
89
import subprocess
910
import sys
@@ -164,16 +165,18 @@ def get_externals() -> list[str]:
164165

165166

166167
def download_with_retries(download_location: str,
167-
max_retries: int = 5,
168-
base_delay: float = 2.0) -> typing.Any:
168+
max_retries: int = 7,
169+
base_delay: float = 2.25,
170+
max_jitter: float = 1.0) -> typing.Any:
169171
"""Download a file with exponential backoff retry."""
170172
for attempt in range(max_retries):
171173
try:
172174
resp = urllib.request.urlopen(download_location)
173175
except urllib.error.URLError as ex:
174176
if attempt == max_retries:
175-
raise ex
176-
time.sleep(base_delay**attempt)
177+
msg = f"Download from {download_location} failed."
178+
raise OSError(msg) from ex
179+
time.sleep(base_delay**attempt + random.uniform(0, max_jitter))
177180
else:
178181
return resp
179182

0 commit comments

Comments
 (0)