Python 2.6 ftplib has timeout parameter, but how to detect a timeout

B

Brendan

I was quite happy to see that ftplib in Python 2.6 now has a timeout
parameter. With large file downloads my script would often hang,
presumably from timing out. Now that there is a timeout parameter, how
would I detect when a timeout occurs?
 
A

Aahz

I was quite happy to see that ftplib in Python 2.6 now has a timeout
parameter. With large file downloads my script would often hang,
presumably from timing out. Now that there is a timeout parameter, how
would I detect when a timeout occurs?

Without looking at code or docs, I assume you get an exception.
 
G

Giampaolo Rodola'

I was quite happy to see that ftplib in Python 2.6 now has a timeout
parameter. With large file downloads my script would often hang,
presumably from timing out. Now that there is a timeout parameter, how
would I detect when a timeout occurs?

The socket object will raise a timeout exception during recv() or send
().


--- Giampaolo
http://code.google.com/p/pyftpdlib
 
M

MrJean1

Brendan,

The timeout argument of the FTP class (and the connect method) is used
only to establish the connection to FTP sockets. If the timeout
expires, an error called socket.timeout is raised.

AFAIK, the timeout argument does not limit FTP transfers. To impose a
time limit on FTP transfers, try using the timelimited function from
this recipe:

<http://code.activestate.com/recipes/576780/>

/Jean
 
G

Giampaolo Rodola'

Brendan,

The timeout argument of the FTP class (and the connect method) is used
only to establish the connection to FTP sockets.  If the timeout
expires, an error called socket.timeout is raised.

AFAIK, the timeout argument does not limit FTP transfers.  To impose a
time limit on FTP transfers, try using the timelimited function from
this recipe:

 <http://code.activestate.com/recipes/576780/>

/Jean

Sorry, I forgot about this.
I had also opened a ticket for this, a long time ago:
http://bugs.python.org/issue4814

--- Giampaolo
http://code.google.com/p/pyftpdlib
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top