[Web-SIG] A 'shutdown' function in WSGI

Tarek Ziadé ziade.tarek at gmail.com
Tue Feb 21 12:30:51 CET 2012


On Tue, Feb 21, 2012 at 11:07 AM, Simon Sapin <simon.sapin at exyr.org> wrote:

> ...



> So a super-set of WSGI that is not just a gateway but also does process
> management?
>
>
> @contextlib.contextmanager
> def super_application(server_**infos):
>    with contextlib.closing(open_**resource()) as resource:
>        wsgi_callable = make_app(server_infos, resource)
>        yield wsgi_callable
>

I like this form a lot, but I think this is an implementation detail --
since we've not answered to the main question yet.

Here's my attempt to formulate how I understand the problem at this point

current assumptions/limitations:

-  the application can be shutdown without handling a request / which makes
it orthogonal to the requests handling
-  the underlying code may use threads, making it unreliable to use atexit()
-  using signals may be problematic if some other code use it too -- for
example the wsgi server itself

-> the cleanest way seems to ask the web server itself to ping the wsgi app.

problems:

- how can we declare a shutdown entry point in the application, the web
server can use.
- how can this work with extra indirections (FASTCGI, etc)

leads:
- define startup/shutdown functions, declare them to the web server
- use the existing environ to send a 'shutdown request'
-

Cheers
Tarek

-- 
Tarek Ziadé | http://ziade.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/web-sig/attachments/20120221/c2394a56/attachment.html>


More information about the Web-SIG mailing list