From 2eefccaddbc763b8db777381ea88826b42e0a4b8 Mon Sep 17 00:00:00 2001 From: "wtc@chromium.org" Date: Thu, 9 Jan 2014 20:41:16 +0000 Subject: [PATCH] Handle the PrimeLint SSL read timeout better. It takes more than 10 seconds to lint some CLs. Silently ignore the expected timeout. R=maruel@chromium.org,iannucci@chromium.org BUG=290402 TEST=none Review URL: https://codereview.chromium.org/130493002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@243968 0039d316-1c4b-4281-b951-d872f2087c98 --- gcl.py | 11 +++++++++-- tests/gcl_unittest.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gcl.py b/gcl.py index db1e5b3eb..1249480d2 100755 --- a/gcl.py +++ b/gcl.py @@ -13,6 +13,7 @@ import optparse import os import random import re +import ssl import string import sys import tempfile @@ -400,8 +401,14 @@ class ChangeInfo(object): """Do background work on Rietveld to lint the file so that the results are ready when the issue is viewed.""" if self.issue and self.patchset: - self.SendToRietveld('/lint/issue%s_%s' % (self.issue, self.patchset), - timeout=10) + try: + self.SendToRietveld('/lint/issue%s_%s' % (self.issue, self.patchset), + timeout=10) + except ssl.SSLError as e: + # It takes more than 10 seconds to lint some CLs. Silently ignore + # the expected timeout. + if e.message != 'The read operation timed out': + raise def SendToRietveld(self, request_path, timeout=None, **kwargs): """Send a POST/GET to Rietveld. Returns the response body.""" diff --git a/tests/gcl_unittest.py b/tests/gcl_unittest.py index 81823ab73..ba2feacf6 100755 --- a/tests/gcl_unittest.py +++ b/tests/gcl_unittest.py @@ -108,7 +108,7 @@ class GclUnittest(GclTestsBase): 'gclient_utils', 'git_cl', 'json', 'main', 'need_change', 'need_change_and_args', 'no_args', 'optparse', 'os', 'presubmit_support', 'random', 're', 'rietveld', - 'string', 'subprocess2', 'sys', 'tempfile', 'time', + 'ssl', 'string', 'subprocess2', 'sys', 'tempfile', 'time', 'upload', 'urllib2', ] # If this test fails, you should add the relevant test.