11#! /usr/bin/env python3
22
3- import common , os , re , subprocess , sys
3+ import common , os , re , subprocess , sys , time
44
55def checkout_skia (commit ):
66 # Clone Skia
@@ -21,6 +21,30 @@ def checkout_skia(commit):
2121 print ("> Checking out" , commit )
2222 subprocess .check_call (["git" , "-c" , "advice.detachedHead=false" , "checkout" , commit ])
2323
24+ def git_sync_with_retries (max_retries = 3 , backoff_seconds = 5 ):
25+ attempt = 0
26+ while True :
27+ try :
28+ print ("> Running tools/git-sync-deps (attempt {}/{})" .format (attempt + 1 , max_retries + 1 ))
29+ # On Windows we need to disable HTTPS verify
30+ if common .host () == 'windows' :
31+ env = os .environ .copy ()
32+ env ['PYTHONHTTPSVERIFY' ] = '0'
33+ subprocess .check_call ([sys .executable , "tools/git-sync-deps" ], env = env )
34+ else :
35+ subprocess .check_call ([sys .executable , "tools/git-sync-deps" ])
36+ print ("Success" )
37+ break
38+ except subprocess .CalledProcessError as e :
39+ attempt += 1
40+ if attempt > max_retries :
41+ print ("All {} retries failed. Giving up." .format (max_retries ))
42+ raise
43+ else :
44+ wait = backoff_seconds * attempt
45+ print (f"Failed (exit { e .returncode } ), retrying in { wait } s…" )
46+ time .sleep (wait )
47+
2448def main ():
2549 os .chdir (os .path .join (os .path .dirname (__file__ ), os .pardir ))
2650
@@ -40,12 +64,8 @@ def main():
4064
4165 # git deps
4266 print ("> Running tools/git-sync-deps" )
43- if 'windows' == common .host ():
44- env = os .environ .copy ()
45- env ['PYTHONHTTPSVERIFY' ]= '0'
46- subprocess .check_call (["python3" , "tools/git-sync-deps" ], env = env )
47- else :
48- subprocess .check_call (["python3" , "tools/git-sync-deps" ])
67+ # Trying to avoid 429 HTTP Error from Google repos
68+ git_sync_with_retries ()
4969
5070 # fetch ninja
5171 print ("> Fetching ninja" )
0 commit comments