Commit d612e493 authored by hinoka@chromium.org's avatar hinoka@chromium.org

Retry fetching patch from rietveld on a 404

Also added a tiny bit of exponential backoff.

BUG=375479

Review URL: https://codereview.chromium.org/350433003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@291682 0039d316-1c4b-4281-b951-d872f2087c98
parent 8f93f79b
......@@ -97,7 +97,7 @@ class Rietveld(object):
url = '/api/%d' % issue
if messages:
url += '?messages=true'
data = json.loads(self.get(url))
data = json.loads(self.get(url, retry_on_404=True))
data['description'] = '\n'.join(data['description'].strip().splitlines())
return data
......@@ -389,7 +389,7 @@ class Rietveld(object):
ctype, body = upload.EncodeMultipartFormData(data, [])
return self._send(request_path, payload=body, content_type=ctype, **kwargs)
def _send(self, request_path, **kwargs):
def _send(self, request_path, retry_on_404=False, **kwargs):
"""Sends a POST/GET to Rietveld. Returns the response body."""
# rpc_server.Send() assumes timeout=None by default; make sure it's set
# to something reasonable.
......@@ -420,7 +420,10 @@ class Rietveld(object):
except urllib2.HTTPError, e:
if retry >= (maxtries - 1):
raise
if e.code not in (500, 502, 503):
flake_codes = [500, 502, 503]
if retry_on_404:
flake_codes.append(404)
if e.code not in flake_codes:
raise
except urllib2.URLError, e:
if retry >= (maxtries - 1):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment