From fd87617b2818b6448a68485c94d9aba90c02b28d Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Fri, 30 Apr 2010 14:01:05 +0000 Subject: [PATCH] Standardize automatic retry and add a 15 seconds sleep to increase the chances of success Review URL: http://codereview.chromium.org/1812001 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@46067 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient_scm.py | 10 ++++++---- scm.py | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gclient_scm.py b/gclient_scm.py index 5eddf23958..40dccae0a0 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -9,6 +9,7 @@ import os import posixpath import re import subprocess +import time import scm import gclient_utils @@ -252,21 +253,22 @@ class GitWrapper(SCMWrapper): raise gclient_utils.Error('Invalid Upstream') # Update the remotes first so we have all the refs. - for _ in range(3): + for _ in range(10): try: remote_output, remote_err = scm.GIT.Capture( ['remote'] + verbose + ['update'], self.checkout_path, print_error=False) break - except gclient_utils.CheckCallError, e: + except gclient_utils.CheckCallError: # Hackish but at that point, git is known to work so just checking for # 502 in stderr should be fine. if '502' in e.stderr: print str(e) - print "Retrying..." + print "Sleeping 15 seconds and retrying..." + time.sleep(15) continue - raise e + raise if verbose: print remote_output.strip() diff --git a/scm.py b/scm.py index a9b1ecf84b..038d2dd471 100644 --- a/scm.py +++ b/scm.py @@ -11,6 +11,7 @@ import shutil import subprocess import sys import tempfile +import time import xml.dom.minidom import gclient_utils @@ -399,7 +400,7 @@ class SVN(object): }[args[0]] compiled_pattern = re.compile(pattern) # Place an upper limit. - for _ in range(1, 10): + for _ in range(10): previous_list_len = len(file_list) failure = [] @@ -423,6 +424,8 @@ class SVN(object): if args[0] == 'checkout': # An aborted checkout is now an update. args = ['update'] + args[1:] + print "Sleeping 15 seconds and retrying...." + time.sleep(15) continue # No progress was made or an unknown error we aren't sure, bail out. raise