summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-02 18:36:56 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-02 18:36:56 +0000
commit289b9663284fa5812be889598568b52d848d3884 (patch)
tree0886b9cd0cd9ba332d1b1d04f6ee38d3ed3c9dc2 /testing
parent3d3cf800a8aae4cd7ff237714e31f9a217667ad8 (diff)
downloadpdfium-289b9663284fa5812be889598568b52d848d3884.tar.xz
Retry fetching Gold JSON data.
It occasionally times out on the bots. Change-Id: Ie33d77c0e07f932c374c2ca670f982faeed29659 Reviewed-on: https://pdfium-review.googlesource.com/c/43310 Commit-Queue: Lei Zhang <thestig@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'testing')
-rw-r--r--testing/tools/gold.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/testing/tools/gold.py b/testing/tools/gold.py
index 86aea746a0..6905c96bbc 100644
--- a/testing/tools/gold.py
+++ b/testing/tools/gold.py
@@ -71,17 +71,22 @@ class GoldBaseline(object):
cl_number_str = self._properties.get('issue', None)
url = GOLD_BASELINE_URL + ('/' + cl_number_str if cl_number_str else '')
- try:
- response = urllib2.urlopen(url, timeout=2)
- c_type = response.headers.get('Content-type', '')
- EXPECTED_CONTENT_TYPE = 'application/json'
- if c_type != EXPECTED_CONTENT_TYPE:
- raise ValueError('Invalid content type. Got %s instead of %s' % (
- c_type, EXPECTED_CONTENT_TYPE))
- json_data = response.read()
- except (urllib2.HTTPError, urllib2.URLError) as e:
- print ('Error: Unable to read skia gold json from %s: %s' % (url, e))
- return None
+ json_data = ''
+ RETRIES = 5
+ attempts = 0
+ while not json_data and attempts < RETRIES:
+ try:
+ response = urllib2.urlopen(url, timeout=2)
+ c_type = response.headers.get('Content-type', '')
+ EXPECTED_CONTENT_TYPE = 'application/json'
+ if c_type != EXPECTED_CONTENT_TYPE:
+ raise ValueError('Invalid content type. Got %s instead of %s' % (
+ c_type, EXPECTED_CONTENT_TYPE))
+ json_data = response.read()
+ attempts += 1
+ except (urllib2.HTTPError, urllib2.URLError) as e:
+ print ('Error: Unable to read skia gold json from %s: %s' % (url, e))
+ return None
try:
data = json.loads(json_data)