From commits-return-5074-apmail-community-commits-archive=community.apache.org@community.apache.org Mon Feb 20 11:38:38 2017 Return-Path: X-Original-To: apmail-community-commits-archive@minotaur.apache.org Delivered-To: apmail-community-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ECCB619BD8 for ; Mon, 20 Feb 2017 11:38:38 +0000 (UTC) Received: (qmail 60747 invoked by uid 500); 20 Feb 2017 11:38:38 -0000 Delivered-To: apmail-community-commits-archive@community.apache.org Received: (qmail 60721 invoked by uid 500); 20 Feb 2017 11:38:38 -0000 Mailing-List: contact commits-help@community.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@community.apache.org Delivered-To: mailing list commits@community.apache.org Received: (qmail 60712 invoked by uid 99); 20 Feb 2017 11:38:38 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Feb 2017 11:38:38 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 24FC73A00A3 for ; Mon, 20 Feb 2017 11:38:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1783745 - /comdev/reporter.apache.org/trunk/scripts/urlutils.py Date: Mon, 20 Feb 2017 11:38:37 -0000 To: commits@community.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170220113838.24FC73A00A3@svn01-us-west.apache.org> Author: sebb Date: Mon Feb 20 11:38:37 2017 New Revision: 1783745 URL: http://svn.apache.org/viewvc?rev=1783745&view=rev Log: Ensure request times out Modified: comdev/reporter.apache.org/trunk/scripts/urlutils.py Modified: comdev/reporter.apache.org/trunk/scripts/urlutils.py URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/scripts/urlutils.py?rev=1783745&r1=1783744&r2=1783745&view=diff ============================================================================== --- comdev/reporter.apache.org/trunk/scripts/urlutils.py (original) +++ comdev/reporter.apache.org/trunk/scripts/urlutils.py Mon Feb 20 11:38:37 2017 @@ -28,6 +28,8 @@ import calendar # time format used in Last-Modified/If-Modified-Since HTTP headers _HTTP_TIME_FORMAT = '%a, %d %b %Y %H:%M:%S GMT' +URL_TIMEOUT = 60.0 # timeout for URL requests (may need tweaking) + # Allow callers to check HTTP code from Python2 and 3 def isHTTPNotFound(e): return type(e) == HTTPError and e.code == 404 @@ -71,7 +73,7 @@ def getIfNewer(url, sinceTime, encoding= try: if not silent: print("%s %s" % (url, headers)) req = Request(url, headers=headers) - resp = urlopen(req) + resp = urlopen(req, timeout=URL_TIMEOUT) # Debug - detect why json sometimes returned as HTML but no error code if debug and not silent: print("STATUS %s" % resp.getcode()) # Works for Py2/3 if debug and not silent: print(resp.headers)