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.

Author r.david.murray
Recipients arloclarke, r.david.murray
Date 2017-07-18.00:53:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1500339211.05.0.663069814192.issue30956@psf.upfronthosting.co.za>
In-reply-to
Content
Given:

import socket
from ftplib import FTP
try:
    ftp = FTP('host.i.know.will.hang.com', timeout=4)
except socket.timeout:
    print('caught')

I see 'caught' printed on the console.  However, if I increase the timeout to 400, then on both 3.5 tip and 3.6 tip I get a TimeoutError, not a socket.timeout.  If I increase the timeout to 4000, I get the TimeoutError in a much shorter time than 4000 seconds.

So, *something* is wrong here.  Looking at the code it isn't obvious what.

Here is the traceback:

Traceback (most recent call last):
  File "../p36/temp.py", line 4, in <module>
    ftp = FTP('xxxx', timeout=4)
  File "/home/rdmurray/python/p35/Lib/ftplib.py", line 118, in __init__
    self.connect(host)
  File "/home/rdmurray/python/p35/Lib/ftplib.py", line 153, in connect
    source_address=self.source_address)
  File "/home/rdmurray/python/p35/Lib/socket.py", line 712, in create_connection
    raise err
  File "/home/rdmurray/python/p35/Lib/socket.py", line 703, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out


Your traceback is different because your timeout is occurring after the initial connection.  Are you sure your socket.timeout is the correct one?  You might try printing socket.__file__ to check.
History
Date User Action Args
2017-07-18 00:53:31r.david.murraysetrecipients: + r.david.murray, arloclarke
2017-07-18 00:53:31r.david.murraysetmessageid: <1500339211.05.0.663069814192.issue30956@psf.upfronthosting.co.za>
2017-07-18 00:53:31r.david.murraylinkissue30956 messages
2017-07-18 00:53:29r.david.murraycreate