From b8aa3e43c758c7614c549dabedbd4544fda1259a Mon Sep 17 00:00:00 2001 From: "antoine.pitrou" Date: Sun, 1 Nov 2009 22:02:03 +0000 Subject: [PATCH] Use a custom timeout in test_support.open_urlresource. git-svn-id: http://svn.python.org/projects/python/trunk@76037 6015fed2-1504-0410-9fe1-9d1591cc4771 --- Lib/test/test_support.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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) -- 2.11.4.GIT