ftplib -- how to timeout a connection
James Sleeman
bitsy_boffin at cyberdude.com
Sat Apr 28 15:08:11 EDT 2001
Hi all,
I have written a small multi threaded application using a
pygtk/python-gnome/glade interface which polls a list of FTP sites tring
to either get a recursive directory listing, or download a file. Each
site is only hit once in every x seconds. I wrote it to leech files from
very busy sites with small maximum users and hmmering protection.
Anyway...for the averge FTP site this works great, i rack up 8 threads
polling sites and the main thread handling the GUI (for adding/editing
sites, queueing files, and displaying status). However it
seems I have a few problem sites in there... when the thread tries to
connect to the site it sits for maybe 2 minutes before it gives up trying
to connect. I want some way of specifying a connect timeout such that if
the connection phase (including login) has not completed in n seconds
that it should fail (throw an exception) then and there.
Can anybody think of a way I can do this ?
Really I'd like something like this....
try :
self.ftpConnection = FTP()
self.ftpConnection.connect(self.Host, self.Port)
self.ftpConnection.login(self.User, self.Pass)
except connectTimeout :
blah blah blah....
Ideas anyone ?
---
James Sleeman
More information about the Python-list
mailing list