Skip to content

Commit 751a890

Browse files
authored
[3.13] gh-134262: increase retries in Tools/build/generate_sbom.py … (#137496)
[3.13] gh-134262: increase retries in `Tools/build/generate_sbom.py` (GH-134558) (cherry picked from commit 3f9eb55)
1 parent 7762de2 commit 751a890

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
@@ -1,5 +1,6 @@
11
"""Tool for generating Software Bill of Materials (SBOM) for Python's dependencies"""
22
import os
3+
import random
34
import re
45
import hashlib
56
import json
@@ -167,16 +168,18 @@ def get_externals() -> list[str]:
167168

168169

169170
def download_with_retries(download_location: str,
170-
max_retries: int = 5,
171-
base_delay: float = 2.0) -> typing.Any:
171+
max_retries: int = 7,
172+
base_delay: float = 2.25,
173+
max_jitter: float = 1.0) -> typing.Any:
172174
"""Download a file with exponential backoff retry."""
173175
for attempt in range(max_retries):
174176
try:
175177
resp = urllib.request.urlopen(download_location)
176178
except urllib.error.URLError as ex:
177179
if attempt == max_retries:
178-
raise ex
179-
time.sleep(base_delay**attempt)
180+
msg = f"Download from {download_location} failed."
181+
raise OSError(msg) from ex
182+
time.sleep(base_delay**attempt + random.uniform(0, max_jitter))
180183
else:
181184
return resp
182185

0 commit comments

Comments
 (0)