How to kill a SocketServer?

Donn Cave donn at u.washington.edu
Mon Apr 12 23:15:58 CEST 2004


In article <c5esmh$h8$1 at newshispeed.ch>,
 "Jean-Pierre Bergamin" <james at ractive.ch> wrote:

> ... The problem is the following:
> The server waits for a connection and it calls in
> SocketServer.TCPServer.handle_request() the function self.socket.accept().
> This call blocks until a connections is made.
> 
> I have no chance to interrupt this call. I also tried:
> 
> def stop_server:
>     self.socket.shutdown(2)
>     self.socket.close()
>     self.run_me = False
> 
> The accept() call still won't get interrupted. :-(
> 
> Other ideas?

I seem to recall a very similar question last week, so you
might look around to see what answers that one got.  There
was at least one that proposed a connection to the service.
That makes a lot of sense to me, especially if you're in a
position to change the service protocol if necessary.

   Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list