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

Unified Diff: tools/findit/common/http_client_local.py

Issue 538383002: [Findit] Make Findit more robust. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Workaround python bug. Created 6 years, 3 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
Index: tools/findit/common/http_client_local.py
diff --git a/tools/findit/common/http_client_local.py b/tools/findit/common/http_client_local.py
index fccb0b60266b44fe1300a6d77e78b195685ab671..8907bc03c15cddde2f844537f6e5fb2861c5b97a 100644
--- a/tools/findit/common/http_client_local.py
+++ b/tools/findit/common/http_client_local.py
@@ -21,6 +21,7 @@ import os
import re
import socket
import ssl
+import time
import urllib
import urllib2
@@ -225,7 +226,25 @@ class HttpClientLocal(http_client.HttpClient):
"""This http client is used locally in a workstation, GCE VMs, etc."""
@staticmethod
- def Get(url, params={}, timeout=None):
+ def Get(url, params={}, timeout=60, retries=5, retry_interval=0.5,
+ retry_if_not=None):
if params:
url = '%s?%s' % (url, urllib.urlencode(params))
- return _SendRequest(url, timeout=timeout)
+
+ count = 0
+ while True:
+ count += 1
+
+ status_code, content = _SendRequest(url, timeout=timeout)
+ if status_code == 200:
+ return status_code, content
+ if retry_if_not and status_code == retry_if_not:
+ return status_code, content
+
+ if count < retries:
+ time.sleep(retry_interval)
+ else:
+ return status_code, content
+
+ # Should never be reached.
+ return status_code, content

Powered by Google App Engine
This is Rietveld 408576698