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

Antoine Pitrou solipsis at pitrou.net
Tue Feb 21 13:43:40 CET 2012

Tarek Ziadé <ziade.tarek at ...> writes:
> On Tue, Feb 21, 2012 at 10:24 AM, Graham Dumpleton
<graham.dumpleton at gmail.com> wrote:
> ...
> > But I don't think you can guarantee that everything is still up in memory by
> > the time atexit gets called,
> > so you can't really call cleanup code there.
> The only thing which is done prior to atexit callbacks being called is
> waiting on threads which weren't marked as daemonised.
> which can lead to completely lock the shutdown if a lib or the program has a
> thread with a loop that waits for a condition.which it is not the case with
> signals, since you get a chance to properly stop everything beforehand.

That's a buggy lib or program. This has nothing to do with WSGI really. The
snippet Graham showed is run at any interpreter shutdown, even when you simply
run "python" in your shell.



More information about the Web-SIG mailing list