Problem exiting application in Windows Console.

Gabriel Genellina gagsl-py at yahoo.com.ar
Wed Nov 8 20:55:40 CET 2006


At Wednesday 8/11/2006 09:10, Ant wrote:

[getting a stack trace for SystemExit instead of a clean exit]

>class HelpHTTPRequestHandler(SimpleHTTPRequestHandler):
>     def do_GET(self):
>         print "PATH: ", self.path
>         if self.path.endswith("quit.html"):
>             print "Exiting..."
>             sys.exit(0)
>         else:
>             return SimpleHTTPRequestHandler.do_GET(self)
>
>def help(base_dir, server_class=HTTPServer,
>handler_class=HelpHTTPRequestHandler):
>     os.chdir(base_dir)
>     server_address = ('', 8000)
>     httpd = server_class(server_address, handler_class)
>     server_thread = Thread(target=httpd.serve_forever)
>     server_thread.start()
>
>     webbrowser.open("http://localhost:8000/index.html")
>
>     print "Hit CTRL-Break or CTRL-C to exit server"

Replace serve_forever with your own loop checking an exit flag, and 
set the flag in your "quit.html" handler instead of sys.exit(0)


-- 
Gabriel Genellina
Softlab SRL 

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar



More information about the Python-list mailing list