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 44import hashlib
55import json
66import os
7+ import random
78import re
89import subprocess
910import sys
@@ -164,16 +165,18 @@ def get_externals() -> list[str]:
164165
165166
166167def 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
You can’t perform that action at this time.
0 commit comments