1
1
#! /usr/bin/env python3
2
2
3
- import common , os , re , subprocess , sys
3
+ import common , os , re , subprocess , sys , time
4
4
5
5
def checkout_skia (commit ):
6
6
# Clone Skia
@@ -21,6 +21,30 @@ def checkout_skia(commit):
21
21
print ("> Checking out" , commit )
22
22
subprocess .check_call (["git" , "-c" , "advice.detachedHead=false" , "checkout" , commit ])
23
23
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
+
24
48
def main ():
25
49
os .chdir (os .path .join (os .path .dirname (__file__ ), os .pardir ))
26
50
@@ -40,12 +64,8 @@ def main():
40
64
41
65
# git deps
42
66
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 ()
49
69
50
70
# fetch ninja
51
71
print ("> Fetching ninja" )
0 commit comments