On Tue, Feb 21, 2012 at 1:43 PM, Antoine Pitrou <solip...@pitrou.net> wrote:
> Tarek Ziadé <ziade.tarek@...> writes: > > > > > > On Tue, Feb 21, 2012 at 10:24 AM, Graham Dumpleton > <graham.dumple...@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. No, that has to do with : please let me clean my program before you try to kill it because I can't use signals :) > The > snippet Graham showed is run at any interpreter shutdown, even when you > simply > run "python" in your shell. > here's a very simple demo: http://tarek.pastebin.mozilla.org/1489505 Run it with plain python, and try to ctrl-C it. You won't reach atexit and will get locked. (here: python 2.7 / mac os) If you use signals instead of atexit, you'll have it working. And this pattern (a thread in the background) is pretty common -- unless I am missing something here Cheers Tarek > > Regards > > Antoine. > > > _______________________________________________ > 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/ziade.tarek%40gmail.com > -- Tarek Ziadé | http://ziade.org
_______________________________________________ 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