socket wedged forever in recv()

Geoffrey Talvola gtalvola at nameconnector.com
Fri Jan 24 16:47:19 EST 2003


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?

I have a couple of ideas for workarounds.  timeoutsocket.py (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.

The only other idea I had was to make these http requests in a separate
thread so that I can detect the wedge and deal with it.  Ugly, but it might
work.

- Geoff

(1) http://www.timo-tasi.org/python/timeoutsocket.py





More information about the Python-list mailing list