socket wedged forever in recv()

Geoffrey Talvola gtalvola at
Mon Jan 27 17:41:13 CET 2003

Richard Jones [mailto:rjones at] wrote:
> On Sat, 25 Jan 2003 8:47 am, Geoffrey Talvola wrote:
> > I have a Windows NT client application that uses httplib to 
> > make requests
> > to a Windows NT server running Apache 2.0 serving up a cgi script.
> > Unfortunately, if I reboot the Apache server, if a request 
> > is in-progress,
> > the client will often wedge permanently.  I built a debug 
> > version of Python
> > 2.2.2 and verified that the client is stuck in a call to 
> > recv() and will
> > apparently never exit.  It's a little irritating that the 
> > client can't
> > detect the situation and return from recv() with an error 
> > code at this
> > point.  Does anyone know a way to get the client to notice 
> > that the server
> > is gone?
> With a timeout, as you've already discovered.
> > I have a couple of ideas for workarounds. 
> > (1) can avoid
> > the problem for non-SSL connections but it doesn't work for 
> > SSL connections
> > at all, and my application needs to make some SSL 
> > connections as well as
> > non-SSL connections.  I'm also going to try Python 2.3a1 to 
> > see if its new
> > support for timeout on sockets works with SSL.
> Apparently this _is_ fixed in 2.3

Unfortunately, this appears to be broken in 2.3a1 -- if you try to set a
timeout on the socket of a HTTPSConnection object, the CPU usage shoots up
to 100% and memory usage skyrockets but you still don't get the timeout you
wanted.  I'm going to enter a bug report about this.

The good news is that I figured out how to patch so that it
_does_ work with SSL, without having to upgrade to Python 2.3.  I've sent
the patch to the author of so presumably he'll release a
new version if he likes my patch, but if you want it sooner, just email me
and I'll send you the patch.

- Geoff

More information about the Python-list mailing list