How to kill a SocketServer?

Paul Rubin http
Sun May 1 22:03:20 EDT 2005


Skip Montanaro <skip at pobox.com> writes:
>     def serve_forever(self):
>         while self.serving:
>             r,w,e = select.select([self.socket], [], [], self.pause)
>             if r:
>                 self.handle_request()
> 
> and set self.pause to something short-ish.  The select call times out and
> the server exits.

Ah, good point.  Something like this should probably be added to
SocketServer.py (optional timeout parameter to serve_forever), or at
least the trick should be mentioned in the docs.

Thanks.



More information about the Python-list mailing list