File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1
1
"""Tool for generating Software Bill of Materials (SBOM) for Python's dependencies"""
2
2
import os
3
+ import random
3
4
import re
4
5
import hashlib
5
6
import json
@@ -167,16 +168,18 @@ def get_externals() -> list[str]:
167
168
168
169
169
170
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 :
172
174
"""Download a file with exponential backoff retry."""
173
175
for attempt in range (max_retries ):
174
176
try :
175
177
resp = urllib .request .urlopen (download_location )
176
178
except urllib .error .URLError as ex :
177
179
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 ))
180
183
else :
181
184
return resp
182
185
You can’t perform that action at this time.
0 commit comments