This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: support.transient_internet() doesn't catch timeout on FTP tests of test_urllib2net
Type: Stage: resolved
Components: Tests Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, ned.deily, python-dev, vstinner
Priority: normal Keywords: patch

Created on 2014-08-27 12:27 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
transient_internet_ftp_timeout.patch vstinner, 2014-08-27 12:27 review
issue22289_3x.patch ned.deily, 2015-03-22 08:01
Messages (6)
msg225979 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-08-27 12:27
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')>
msg229965 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-10-24 22:46
There seems to be a small problem with the patch that can be easily fixed by changing the test for "ftp error: timeout()" to "ftp error: timeout(".  Otherwise, it seems OK.  Note that there is now also a related patch for Issue22596 that modifies the same test.  Perhaps they can be combined.
msg238883 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2015-03-22 08:01
Here's an updated patch for 3.4 and default.  To test it, I had to inject a faulty test server with a timeout error, as the test with the dead URL skips properly on my system.  For 2.7, the test doesn't fail for me even with the injected server so I propose not bothering to change anything there.
msg238884 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-03-22 08:09
The patch looks good to me.
msg238885 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-03-22 08:19
New changeset 9eb1ce7d8039 by Ned Deily in branch '3.4':
Issue #22289: Prevent test_urllib2net failures due to ftp connection timeout.
https://hg.python.org/cpython/rev/9eb1ce7d8039

New changeset 1aad901e0307 by Ned Deily in branch 'default':
Issue #22289: merge from 3.4
https://hg.python.org/cpython/rev/1aad901e0307
msg238886 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2015-03-22 08:40
Thanks for the review.  Fix committed for release in 3.4.4 and 3.5.0.
History
Date User Action Args
2022-04-11 14:58:07adminsetgithub: 66485
2015-03-22 08:40:21ned.deilysetstatus: open -> closed
versions: - Python 2.7
messages: + msg238886

resolution: fixed
stage: commit review -> resolved
2015-03-22 08:19:40python-devsetnosy: + python-dev
messages: + msg238885
2015-03-22 08:09:24vstinnersetmessages: + msg238884
2015-03-22 08:01:40ned.deilysetfiles: + issue22289_3x.patch

messages: + msg238883
stage: patch review -> commit review
2014-10-24 22:46:08ned.deilysetnosy: + berker.peksag, ned.deily

messages: + msg229965
stage: patch review
2014-08-27 12:27:29vstinnercreate