Re: [Python-Dev] Regarding socket timeouts in httplib

2010-07-01 Thread R. David Murray
On Thu, 01 Jul 2010 10:33:30 +0200, Anders Sandvig wrote: > >From the top of my head, I can come up with three (four) ways of > properly solving the issue: > > 1) Documenting the timeout behavior and describing the above hack in > the httplib documentation. > > 2) Modify HTTPConnection.connect(

Re: [Python-Dev] Regarding socket timeouts in httplib

2010-07-01 Thread Simon Cross
On Thu, Jul 1, 2010 at 10:33 AM, Anders Sandvig wrote: > 2) Modify HTTPConnection.connect() to set the timeout on the socket > object after it has been  created (using the same timeout as given on > the HTTPConnection constructor). It looks like urllib2 in trunk and urllib.request in py3k are als

[Python-Dev] Regarding socket timeouts in httplib

2010-07-01 Thread Anders Sandvig
Consider the following code for retreieving a web page using httplib:    def get_url(hostname, port, url, timeout=5):        con = httplib.HTTPConnection(hostname, port, timeout)        con.request("GET", url)        res = con.getresponse()        data = res.read()        return res, data As expe