Socket timeouts for HTTP connections (httplib)?

Matt Russell matt at teaphoo.fsnet.co.uk
Fri Apr 4 17:42:08 EST 2003


I have recently posted a patch to sf regarding ftplib, which has the
same problem (no way to use ne wtimeout functionailty).


I have recently found that for classes ftplib.FTP, poplib.POP3,
imaplib.IMAP, telnetlib.Telnet, smtplib.SMTP and
httplib.HTTPConnection all have very similar connect methods. Assuming
my patch will be taken on board, it will allow access to the socket
timeout from each of these classes via optional parameters to connect
and settimeout/gettimeout on each class in question.

Would being able to  do:

conn  = httllib.HTTP(url, timeout=n)
conn.settimeout(n)
...
conn.send("<data>")

solve your problem?

do u need this functionailty now?


Matt Russell


nick_bower at yahoo.com.au (nick) wrote in message 
news:<9df3d134.0304020550.7e32bf6b at posting.google.com>...
> I'm using httplib in a threaded HTTP load imparting test suite for our
> portal.  A problem is that HTTP GETs often hang, blocking my
> requesting threads.  I was highly disapointed to find, after writing
> my test suite, that no high-level HTTP timeout functionality exists in
> Python.
> 
> I have neither an expert understanding of socket programming,
> threading or asyncronous IO, yet can get by using threading.Thread and
> httplib.  I am therefore looking for a timeout at a fairly high level
> (ie the httplib api).
> 
> There were rumblings about Guido implementing this at a socket level
> in June 2002, but I've not been able to find anything since. 
> Presumably this has not yet risen up into httplib either because the
> python.org documentation doesn't mention it.
> 
> Has/is someone involved with this?  timeoutsocket simply doesn't work
> for me and throws continuous "connection reset by peer" exceptions. 
> So I'm completely stuck for options.
> 
> Thanks, Nick




More information about the Python-list mailing list