How to kill a SocketServer?

Paul Rubin http
Sun May 1 14:45:25 EDT 2005


Skip Montanaro <skip at pobox.com> writes:
> I use precisely that scheme with (I think *) no problem.  The only maybe
> significant difference I see is that I subclass ThreadingMixin so that it
> creates daemon threads: ...

According to the docs, you don't need the subclass, you can just set the
"daemon_threads" property on the server, e.g.

    class myserver(ThreadingMixIn, TCPServer): pass
    server = myserver(...)
    server.daemon_threads = True
    server.serve_forever()

You have to set the flag before you actually start the server, as above.

> (*) Maybe my XML-RPC server actually accepts one more connection after I set
> server.shutdown to True before it actually exits.  I'll have to take a look
> at that.

Yes, this is precisely what I'm asking.  How do you get the server to
go away without going out of your way to connect to it again?  Don't you
notice if it stays around?



More information about the Python-list mailing list