summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-10 16:52:20 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-10 16:52:20 +0000
commitb3a0fc30102042be6f5db0c1f644cc21ec69394a (patch)
tree75b82e88734fe865bd5efe4965a0e3f861f15402
parent76ec926e732926e84de9c8b4ef0018464172e73b (diff)
downloadpdfium-b3a0fc30102042be6f5db0c1f644cc21ec69394a.tar.xz
Catch SSL errors when fetching Gold JSON data.
Also increase timeout value when retrying. Change-Id: I14dd3f76fd1a7555c3a5e1bd8c7bf8f214bc8ec0 Reviewed-on: https://pdfium-review.googlesource.com/c/43616 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--testing/tools/gold.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/testing/tools/gold.py b/testing/tools/gold.py
index ce158be319..2987508ccf 100644
--- a/testing/tools/gold.py
+++ b/testing/tools/gold.py
@@ -7,6 +7,7 @@ import json
import os
import shlex
import shutil
+import ssl
import urllib2
@@ -72,19 +73,22 @@ class GoldBaseline(object):
url = GOLD_BASELINE_URL + ('/' + cl_number_str if cl_number_str else '')
json_data = ''
- RETRIES = 5
- attempts = 0
- while not json_data and attempts < RETRIES:
+ MAX_TIMEOUT = 33 # 5 tries. (2, 4, 8, 16, 32)
+ timeout = 2
+ while True:
try:
- response = urllib2.urlopen(url, timeout=2)
+ response = urllib2.urlopen(url, timeout=timeout)
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:
+ break # If this line is reached, then no exception occurred.
+ except (ssl.SSLError, urllib2.HTTPError, urllib2.URLError) as e:
+ timeout *= 2
+ if timeout < MAX_TIMEOUT:
+ continue
print ('Error: Unable to read skia gold json from %s: %s' % (url, e))
return None