closing a server socket
Peter Hansen
peter at engcorp.com
Fri Oct 17 15:30:14 EDT 2003
simon place wrote:
>
> i'm trying to see if anyone else thinks this is a bug,
>
> when you call socket.socket.close() the wrapper only marks the socket as
> closed, so no exception to unblock socket.socket.accept(), and you can
> actually still get connections on this socket?
>
> ( this may only be for windows. )
A repost? What didn't you like about my previous replies?
I guess you are basically saying that you want to use a blocking
socket (because you can't get non-blocking ones to work, though they
do work in general?) but you still want to be able to terminate
your call from another thread by forcibly closing the socket...
If that's so, give it up. You can't do that because the
accept() call is stuck down in C code which can't be
interrupted from another Python thread. Your only hope would be
to have the server call be in a separate process, which you
could "kill", but then you'd of course have to talk to this
other process with sockets, and be back where you started.
Use non-blocking sockets. They do work.
-Peter
More information about the Python-list
mailing list