What is the timeout value of HTTP

K

ken

Can you please tell me what is the timeout value of httplib.HTTP?

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.
 
A

Alex Martelli

ken said:
Can you please tell me what is the timeout value of httplib.HTTP?

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()

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
 
F

Facundo Batista

ken said:
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:

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,
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top