Le 21/02/2012 01:18, Chris McDonough a écrit :
On Mon, 2012-02-20 at 17:39 -0500, PJ Eby wrote:
> The standard way to do this would be to define an "optional server
> extension" API supplied in the environ; for example, a
> 'x-wsgiorg.register_shutdown' function.
Unlikely, AFACIT, as shutdown may happen when no request is active.
Even if this somehow happened to not be the case, asking the application
to put it in the environ is not useful, as the environ can't really be
relied on to retain values "up" the call stack.
Hi,
I like environ['x-wsgiorg.register_shutdown']. It would work without
changes to WSGI itself.
I think that the idea is not to put your shutdown function in the
environment and hope it stays there "up" the stack, but to register it
by calling register_shutdown:
@environ.get('x-wsgiorg.register_shutdown', lambda f: f)
def do_cleanup():
pass
Also, a shutdown function would be used to clean up something that was
set up in a request. So if the server shuts down without having ever
served a request, there probably is nothing to clean up.
Regards,
--
Simon Sapin
_______________________________________________
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe:
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com