closing a "forever" Server Socket

Matimus mccredie at gmail.com
Thu Jan 18 13:08:35 EST 2007


> I want to ask if someone knows a better way for closing a "forever
> server" or if there is a lack in my design.

Generally you don't create a 'forever server'. You create an 'until I
say stop' server. I would do this by looking at the 'serve_forever'
method, and implementing my own 'serve_until_?' method that is similar,
but will stop if a flag is set. Then you have to create a method for
setting that flag. It could be as simple as a keypress, or you could
add a quit method to your dispatcher that sets the flag when a certain
address is visited. That second method probably needs some added
security, otherwise anybody can just visit 'your.server.com/quit' and
shut it down.




More information about the Python-list mailing list