Stopping SocketServer on Python 2.5

Falcolas garrickp at gmail.com
Wed Mar 11 13:57:28 EDT 2009


On Mar 10, 7:19 pm, David George <d... at eatmyhat.co.uk> wrote:
> So, my question is, is there any way to stop a SocketServer that's been
> told to server forever in python 2.5?

serve_forever, in python 2.5, is simply coded as:

while 1:
    self.handle_request()

So, instead of calling serve_forever, call handle_request in your own
loop with a shutdown flag. Assuming, of course, that you aren't using
the Forking server, in which case things get more interesting.

~G



More information about the Python-list mailing list