how to stop a server (TCPServer, for example)
wang at rjka.com
Tue Aug 21 19:34:28 CEST 2001
thanks and it works!
do you think it is reasonable to patch the SocketServer.py so that
it is easier to write request handler to stop the server?
I am thinking a simple patch to BaseServer class in SocketServer.py
1) in def __init__(), add:
self.stop = 0
2) change serve_forever to:
while not self.stop:
thanks you again for your help!
From: Skip Montanaro [mailto:skip at pobox.com]
Sent: Tuesday, August 21, 2001 11:02 AM
To: wang at rjka.com
Cc: python-list at python.org
Subject: Re: how to stop a server (TCPServer, for example)
Huayin> How to make the server clean itself up and exit?
Huayin> Do I need to implment an exit method for the server?
That's typical. In my serve_forever method I have (effectively)
r,w,e = select.select([self.socket], , , self.pause)
My exit method simply sets self.serving to 0.
Skip Montanaro (skip at pobox.com)
More information about the Python-list