i.e. how long python will wait for a response in the below code?
h = httplib.HTTP(self.url, 8080)
h.putrequest('GET', '/sample/?url=' + self.url)
h.endheaders()
Thank you.
HTTP per se does not define any timeout -- if self.url is correctly
resolved by DNS and accepts a TCP connection on port 8080, and then just
hangs forever, you'll be waiting. You can force timeouts yourself by
playing with socket.setdefaulttimeout(...) before you start the HTTP
interaction.
Alex
> i.e. how long python will wait for a response in the below code?
>
> h = httplib.HTTP(self.url, 8080)
> h.putrequest('GET', '/sample/?url=' + self.url)
> h.endheaders()
For ever.
In Py<=2.5, httplib.HTTP doesn't have a timeout, so you have to do
something like:
>>> import socket
>>> socket.setdefaulttimeout(...)
>>> h = httplib.HTTP(...)
Beware that *all* sockets created after the call to setdefaulttimeout()
will have that default.
httplib.HTTP now has a timeout, but in the development trunk (you'll
have to checkout the SVN code and compile Python yourself, or wait until
Py2.6).
Regards,
--
. Facundo
.
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/