On Fri, Feb 05, 2010 at 02:31:53PM -0500, michael lovett wrote:
> No I hadn't considered that, but I will!

It won't help if the purpose of running code at server exit is to stop
background threads: Python calls atexit handlers after all non-daemon
threads have terminated.

And if your threads are daemon threads, you don't need to (and probably
can't) shut them down cleanly.

I think the safest way is to wrap the server code (e.g. Paster, if you chose
to use it).  Something like

    def main():
        app = create_my_wsgi_app(...)
        custom_app_startup(app, ...)
        try:
            serve_my_app(app)
        finally:
            custom_app_shutdown(app, ...)

Marius Gedminas
-- 
Inform all the troops that communications have completely broken down.

Attachment: signature.asc
Description: Digital signature

Reply via email to