Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1035)

Unified Diff: rietveld.py

Issue 350433003: Retry fetching patch from rietveld on a 404 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Move to _send() Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: rietveld.py
diff --git a/rietveld.py b/rietveld.py
index f6ccaf928f1041dca6c00100f477a4e141ed796a..0bf3d740e0ef759a78f7046df21a0f3916b6238c 100644
--- a/rietveld.py
+++ b/rietveld.py
@@ -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):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698