Issue 22289: support.transient_internet() doesn't catch timeout on FTP tests of test_urllib2net (original) (raw)

Attached patch should fix the following sporadic error. I wrote the patch for Python 3.5. I will adapt it for Python 2.7 and 3.4 if the review is positive.

http://buildbot.python.org/all/builders/AMD64%20Ubuntu%20LTS%203.x/builds/4837/steps/test/logs/stdio

====================================================================== ERROR: test_ftp_basic (test.test_urllib2net.TimeoutTest)

Traceback (most recent call last): File "/opt/python/3.x.langa-ubuntu/build/Lib/urllib/request.py", line 1388, in ftp_open fw = self.connect_ftp(user, passwd, host, port, dirs, req.timeout) File "/opt/python/3.x.langa-ubuntu/build/Lib/urllib/request.py", line 1410, in connect_ftp persistent=False) File "/opt/python/3.x.langa-ubuntu/build/Lib/urllib/request.py", line 2232, in init self.init() File "/opt/python/3.x.langa-ubuntu/build/Lib/urllib/request.py", line 2238, in init self.ftp.connect(self.host, self.port, self.timeout) File "/opt/python/3.x.langa-ubuntu/build/Lib/ftplib.py", line 153, in connect source_address=self.source_address) File "/opt/python/3.x.langa-ubuntu/build/Lib/socket.py", line 655, in create_connection raise err File "/opt/python/3.x.langa-ubuntu/build/Lib/socket.py", line 646, in create_connection sock.connect(sa) TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/python/3.x.langa-ubuntu/build/Lib/test/test_urllib2net.py", line 308, in test_ftp_basic u = _urlopen_with_retry(self.FTP_HOST) File "/opt/python/3.x.langa-ubuntu/build/Lib/test/test_urllib2net.py", line 33, in wrapped return _retry_thrice(func, exc, *args, **kwargs) File "/opt/python/3.x.langa-ubuntu/build/Lib/test/test_urllib2net.py", line 29, in _retry_thrice raise last_exc File "/opt/python/3.x.langa-ubuntu/build/Lib/test/test_urllib2net.py", line 23, in _retry_thrice return func(*args, **kwargs) File "/opt/python/3.x.langa-ubuntu/build/Lib/urllib/request.py", line 153, in urlopen return opener.open(url, data, timeout) File "/opt/python/3.x.langa-ubuntu/build/Lib/urllib/request.py", line 455, in open response = self._open(req, data) File "/opt/python/3.x.langa-ubuntu/build/Lib/urllib/request.py", line 473, in _open '_open', req) File "/opt/python/3.x.langa-ubuntu/build/Lib/urllib/request.py", line 433, in _call_chain result = func(*args) File "/opt/python/3.x.langa-ubuntu/build/Lib/urllib/request.py", line 1406, in ftp_open raise exc.with_traceback(sys.exc_info()[2]) File "/opt/python/3.x.langa-ubuntu/build/Lib/urllib/request.py", line 1388, in ftp_open fw = self.connect_ftp(user, passwd, host, port, dirs, req.timeout) File "/opt/python/3.x.langa-ubuntu/build/Lib/urllib/request.py", line 1410, in connect_ftp persistent=False) File "/opt/python/3.x.langa-ubuntu/build/Lib/urllib/request.py", line 2232, in init self.init() File "/opt/python/3.x.langa-ubuntu/build/Lib/urllib/request.py", line 2238, in init self.ftp.connect(self.host, self.port, self.timeout) File "/opt/python/3.x.langa-ubuntu/build/Lib/ftplib.py", line 153, in connect source_address=self.source_address) File "/opt/python/3.x.langa-ubuntu/build/Lib/socket.py", line 655, in create_connection raise err File "/opt/python/3.x.langa-ubuntu/build/Lib/socket.py", line 646, in create_connection sock.connect(sa) urllib.error.URLError: <urlopen error ftp error: TimeoutError(110, 'Connection timed out')>