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 11"""Tool for generating Software Bill of Materials (SBOM) for Python's dependencies"""
22import os
3+ import random
34import re
45import hashlib
56import json
@@ -167,16 +168,18 @@ def get_externals() -> list[str]:
167168
168169
169170def 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
You can’t perform that action at this time.
0 commit comments