socket wedged forever in recv()

Geoffrey Talvola gtalvola at nameconnector.com
Sat Jan 25 01:09:21 CET 2003


Peter Hansen [mailto:peter at engcorp.com] wrote:
> 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?
> 
> Use the "select" module.
> 

Agreed.  This is actually how timeoutsocket.py works -- it cleverly replaces
socket objects with a class that behaves like a socket, but uses select with
a timeout.  But timeoutsocket.py doesn't actually work with SSL, apparently
because the SSL support requires a real socket object, not the wrapper
provided by timeoutsocket.py.

But I think I've figured out how to modify timeoutsocket.py so that it wraps
the ssl object too, achieving the effect I need.  I'll submit a patch to the
timeoutsocket maintainer once I'm sure my fix is working.

- Geoff





More information about the Python-list mailing list