[Web-SIG] A 'shutdown' function in WSGI
PJ Eby
pje at telecommunity.com
Tue Feb 21 02:54:28 CET 2012
2012/2/20 Chris McDonough <chrism at plope.com>
> 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.
>
"Optional server extension APIs" are things that the server puts in the
environ, not things the app puts there. That's why it's
'register_shutdown', e.g.
environ['x-wsgiorg.register_shutdown'](shutdown_function).
>
> - C
>
>
> > The wsgi.org wiki used to be the place to propose these sorts of
> > things for standardization, but it appears to no longer be a wiki, so
> > the mailing list is probably a good place to discuss such a proposal.
> >
> > On Mon, Feb 20, 2012 at 2:30 PM, Tarek Ziadé <ziade.tarek at gmail.com>
> > wrote:
> > oops my examples were broken, should be:
> >
> > def hello_world_app(environ, start_response): status = '200
> > OK' # HTTP Status headers = [('Content-type', 'text/plain')]
> > start_response(status, headers) return ["Hello World"]
> >
> > def shutdown(): # or maybe something else as an argument I
> > don't know
> > do_some_cleanup()
> >
> >
> >
> > and:
> >
> > $ gunicorn myapp:hello_world_app myapp:shutdown
> >
> >
> >
> > Cheers
> > Tarek
> >
> > _______________________________________________
> > Web-SIG mailing list
> > Web-SIG at python.org
> > Web SIG: http://www.python.org/sigs/web-sig
> > Unsubscribe:
> > http://mail.python.org/mailman/options/web-sig/pje%
> > 40telecommunity.com
> >
> >
> > _______________________________________________
> > Web-SIG mailing list
> > Web-SIG at python.org
> > Web SIG: http://www.python.org/sigs/web-sig
> > Unsubscribe:
> http://mail.python.org/mailman/options/web-sig/chrism%40plope.com
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/web-sig/attachments/20120220/913fd487/attachment.html>
More information about the Web-SIG
mailing list