SocketServer shutdown?
Dave Brueck
dbrueck at edgix.com
Wed Oct 11 12:36:36 EDT 2000
You don't, otherwise it wouldn't really be serving forever! <g>
serve_forever is just a tiny utility function that does:
while 1:
self.handle_request()
so you could your own:
self.bContinue = 1
while self.bContinue:
self.handle_request()
and elsewhere set the flag to 0 when it's time to quit. Note that it won't
quit until it handles the _next_ request. If this isn't acceptable, you have
to do more work and create your own subclass of SocketServer that makes the
sockets non-blocking. Calls to handle_request will return immediately if no
connections were waiting (an exception gets raised, too), in which case
you'd probably want to add a little delay in your version of serve_forever.
-Dave
> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Paul Johnston
> Sent: Wednesday, October 11, 2000 9:46 AM
> To: python-list at python.org
> Subject: SocketServer shutdown?
>
>
> I'm using the SocketServer class like so:
>
> self.server = SocketServer.ThreadingTCPServer(("",port),
> MessageHandler.MessageHandler)
> self.server.serve_forever()
>
> How do I shutdown the server_forever process - cleanly?
>
> Thanks, Paul
>
>
> --
> http://www.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list