From: Antoine Pitrou Date: Sun, 1 Nov 2009 22:02:03 +0000 (+0000) Subject: Use a custom timeout in test_support.open_urlresource. X-Git-Tag: v2.7a1~167 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84ee9e257ea508284c29effa4253226502b38428;p=python Use a custom timeout in test_support.open_urlresource. --- diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index fa46be2d0c..c2dcb57915 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -463,7 +463,7 @@ def check_syntax_error(testcase, statement): '', 'exec') def open_urlresource(url): - import urllib, urlparse + import urlparse, urllib2 requires('urlfetch') filename = urlparse.urlparse(url)[2].split('/')[-1] # '/': it's URL! @@ -473,7 +473,15 @@ def open_urlresource(url): return open(fn) print >> get_original_stdout(), '\tfetching %s ...' % url - fn, _ = urllib.urlretrieve(url, fn) + f = urllib2.urlopen(url, timeout=15) + try: + with open(fn, "wb") as out: + s = f.read() + while s: + out.write(s) + s = f.read() + finally: + f.close() return open(fn)