how to stop a server (TCPServer, for example)

Skip Montanaro skip at pobox.com
Tue Aug 21 12:01:33 EDT 2001


    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)

    while self.serving:
        r,w,e = select.select([self.socket], [], [], self.pause)
        if r:
            self.handle_request()

My exit method simply sets self.serving to 0.

-- 
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list