From 6c96e493a38edb413794d9135c40503fc988b312 Mon Sep 17 00:00:00 2001 From: "kbr@chromium.org" Date: Tue, 18 Jan 2011 22:10:04 +0000 Subject: [PATCH] Second attempt to work around App Engine flakiness by retrying upon URLError ("Connection timed out"). This allowed me to successfully upload a CL I had been stuck on for a couple of hours. Manually tested by raising both HTTPError and URLError within this code block and ensuring both are caught correctly. BUG=none TEST=none Review URL: http://codereview.chromium.org/6304006 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@71702 0039d316-1c4b-4281-b951-d872f2087c98 --- third_party/upload.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/third_party/upload.py b/third_party/upload.py index f7a2bf5d9..a49d533af 100755 --- a/third_party/upload.py +++ b/third_party/upload.py @@ -416,6 +416,14 @@ class AbstractRpcServer(object): url = e.info()["location"] else: raise + except urllib2.URLError, e: + reason = getattr(e, 'reason', None) + if isinstance(reason, str) and reason.find("110") != -1: + # Connection timeout error. + if tries <= 3: + # Try again. + continue + raise finally: socket.setdefaulttimeout(old_timeout)