This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author neologix
Recipients BreamoreBoy, ajaksu2, giampaolo.rodola, grolich, neologix
Date 2010-09-20.20:06:40
SpamBayes Score 5.5291882e-12
Marked as misclassified No
Message-id <1285013204.13.0.779202384177.issue1531775@psf.upfronthosting.co.za>
In-reply-to
Content
Skimming through the code, the only place where we can reasonably block is inside HTTPConnection._send_output(), when the data is actually sent to the socket.
What probably happens is the following:
- connect() call succeeded, we have an established TCP connection
- before request() is called - or in the middle of the sending - the host at the other host goes down in brutal way, so that we don't receive a FIN/RST: the TCP stack has no clue that the remote host went down
- we keep sending data through the socket, until the socket write buffer fills up, and then, since httplib uses blocking sockets by default, we block on the send() call

Now, depending on the TCP stack setting, after a given number of retries the stack will decide the other host went down, and return an error. But this can take a long time (under Linux, it's set by net.ipv4.tcp_retries2 sysctl by default to 30 minutes).
The only thing that surprises me here is that when the host is back online, we should get a RST, but it depends on the OS, the timeouts, maybe there's a statefull firewall, etc.

So I'd say it's not a httplib issue here, it's just a standard behaviour of a TCP connection when an host goes down.

Note that the solution is simply to use non-blocking socket, and it's already implemented. Heck, it's even documented actually:

class httplib.HTTPConnection(host[, port[, strict[, timeout[, source_address]]]])
If the optional timeout parameter is given, blocking operations (like connection attempts) will timeout after that many seconds (if it is not given, the global default timeout setting is used).

So for me it's not an issue, but given the lack of infos, maybe I got it completely wrong ;-)
History
Date User Action Args
2010-09-20 20:06:44neologixsetrecipients: + neologix, giampaolo.rodola, ajaksu2, grolich, BreamoreBoy
2010-09-20 20:06:44neologixsetmessageid: <1285013204.13.0.779202384177.issue1531775@psf.upfronthosting.co.za>
2010-09-20 20:06:42neologixlinkissue1531775 messages
2010-09-20 20:06:40neologixcreate