Chromium Code Reviews| Index: download_from_google_storage.py |
| diff --git a/download_from_google_storage.py b/download_from_google_storage.py |
| index b186c63ad44f0a9fccaa76eea8c28853b00c7f10..71a8149c735a6adc1334044e672715c9a10cc803 100755 |
| --- a/download_from_google_storage.py |
| +++ b/download_from_google_storage.py |
| @@ -55,6 +55,10 @@ def GetNormalizedPlatform(): |
| class Gsutil(object): |
| """Call gsutil with some predefined settings. This is a convenience object, |
| and is also immutable.""" |
| + |
| + MAX_TRIES = 5 |
| + RETRY_BASE_DELAY = 5.0 |
| + |
| def __init__(self, path, boto_path=None, timeout=None, version='4.15'): |
| if not os.path.exists(path): |
| raise FileNotFoundError('GSUtil not found in %s' % path) |
| @@ -100,6 +104,18 @@ class Gsutil(object): |
| return (404, out, err) |
| return (code, out, err) |
| + def check_call_with_retries(self, *args): |
| + delay = self.RETRY_BASE_DELAY |
| + for i in xrange(self.MAX_TRIES): |
| + code, out, err = self.check_call(*args) |
| + if not code or i == self.MAX_TRIES - 1: |
| + break |
| + |
| + time.sleep(delay) |
| + delay *= 1.3 |
|
tandrii(chromium)
2016/03/24 09:49:24
nit: maybe self.DELAY_MULTIPLE then?
dsansome
2016/03/29 03:24:54
Done.
|
| + |
| + return code, out, err |
| + |
| def check_platform(target): |
| """Checks if any parent directory of target matches (win|mac|linux).""" |