diff options
author | Matt Cotter <matt.cotter@mongodb.com> | 2016-07-20 16:40:22 -0400 |
---|---|---|
committer | Matt Cotter <matt.cotter@mongodb.com> | 2016-07-22 11:32:57 -0400 |
commit | 8b66399b8536dc3120be5444b81ba51d4b8a95e4 (patch) | |
tree | c3c4c7a3e9ec8a8a11789334b9f302e85135efdf /buildscripts/clang_format.py | |
parent | 752fad14e73a57fa7f2a96af8f47ff5cef601cee (diff) | |
download | mongo-8b66399b8536dc3120be5444b81ba51d4b8a95e4.tar.gz |
SERVER-24756 make clang format downloads resistent to http errors
Diffstat (limited to 'buildscripts/clang_format.py')
-rwxr-xr-x | buildscripts/clang_format.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/buildscripts/clang_format.py b/buildscripts/clang_format.py index 890a0744e10..0e9cb7e7416 100755 --- a/buildscripts/clang_format.py +++ b/buildscripts/clang_format.py @@ -23,7 +23,7 @@ import tarfile import tempfile import threading import time -import urllib +import urllib2 from distutils import spawn from optparse import OptionParser from multiprocessing import cpu_count @@ -149,7 +149,19 @@ def get_clang_format_from_cache_and_extract(url, tarball_ext): # Download from file print("Downloading clang-format %s from %s, saving to %s" % (CLANG_FORMAT_VERSION, url, temp_tar_file)) - urllib.urlretrieve(url, temp_tar_file) + + # Retry download up to 5 times. + num_tries = 5 + for attempt in range(num_tries): + try: + resp = urllib2.urlopen(url) + with open(temp_tar_file, 'wb') as f: + f.write(resp.read()) + break + except urllib2.URLError: + if attempt == num_tries - 1: + raise + continue extract_clang_format(temp_tar_file) |