Senthil Kumaran <orsent...@gmail.com> added the comment: Hello Victor,
The patch looks for fine for a timeout enforcement. A couple of changes required. - if isinstance(err[0], timeout): + if isinstance(err[0], socket.timeout): And, in this portion: + try: + with test_support.transient_internet(): + buf = f.read() + except socket.timeout: + print >>sys.stderr, "<timeout: %s>" % url f.close() debug("read %d bytes" % len(buf)) The last line references, buf. It wont be available if a socket.timeout had happened. So, it can simply be moved to the line below buf = f.read(). Attaching the patch with these changes. Question: Were you able to simulate a timeout at kernel.org site to test this? If yes, how? I am unable to simulate (by changing the kernel.org:81, kernel42.org etc), it immediately throws a connection refused. ( In general, I could simulate the timeout by urlopen('www.google.com:81', timeout=30) and test the exception) As build-bot seems to be hung, a timeout enforcement as the patch accomplishes is fine. ---------- Added file: http://bugs.python.org/file16993/test_urllib2net_timeout.patch-2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8460> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com