build: retry external binary downloads a few times (#24110)

This commit is contained in:
Samuel Attard 2020-06-15 14:31:29 -07:00 committed by GitHub
parent c0182bca15
commit 0b830ba9e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -97,10 +97,15 @@ def sha256(file_path):
return hash_256.hexdigest()
def download_binary(base_url, sha, binary_name):
def download_binary(base_url, sha, binary_name, attempt=3):
full_url = '{0}/{1}/{2}'.format(base_url, sha, binary_name)
temp_path = download_to_temp_dir(full_url, filename=binary_name, sha=sha)
return temp_path
try:
temp_path = download_to_temp_dir(full_url, filename=binary_name, sha=sha)
return temp_path
except Exception as e:
if attempt == 1:
raise e
return download_binary(base_url, sha, binary_name, attempt - 1)
def validate_sha(file_path, sha):