What is the timeout value of HTTP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ken

    What is the timeout value of HTTP

    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(se lf.url, 8080)
    h.putrequest('G ET', '/sample/?url=' + self.url)
    h.endheaders()

    Thank you.

  • Alex Martelli

    #2
    Re: What is the timeout value of HTTP

    ken <ken.carlino@gm ail.comwrote:
    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(se lf.url, 8080)
    h.putrequest('G ET', '/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.setdefau lttimeout(...) before you start the HTTP
    interaction.


    Alex

    Comment

    • Facundo Batista

      #3
      Re: What is the timeout value of HTTP

      ken wrote:
      i.e. how long python will wait for a response in the below code?
      >
      h = httplib.HTTP(se lf.url, 8080)
      h.putrequest('G ET', '/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.setdef aulttimeout(... )
      >>h = httplib.HTTP(.. .)
      Beware that *all* sockets created after the call to setdefaulttimeo ut()
      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/


      Comment

      Working...