socket wedged forever in recv()
rjones at ekit-inc.com
Sat Jan 25 05:54:38 CET 2003
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. 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.
Apparently this _is_ fixed in 2.3
> 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
Except you can't kill one thread from another. If you're single-threaded, you
can use an alarm signal to interrupt the process. I think.
More information about the Python-list