community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1783745 - /comdev/reporter.apache.org/trunk/scripts/urlutils.py
Date Mon, 20 Feb 2017 11:38:37 GMT
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)



Mime
View raw message