[Web-SIG] [extension] x-wsgiorg.flush

Phillip J. Eby pje at telecommunity.com
Fri Oct 5 02:22:24 CEST 2007


At 09:03 AM 10/5/2007 +1000, Graham Dumpleton wrote:
>Too early for me to be thinking straight and work it out for myself,
>but does this all help in making it simpler or more obvious what the
>cleanup requirements are for a generator. Ie., correct use of
>try/except/finally around yield and purpose of close() function. I've
>seen a number of people not get this correct in stuff and tried to
>correct them. Hopefully I have captured what should be done correctly
>in my document:
>
>   http://code.google.com/p/modwsgi/wiki/RegisteringCleanupCode

That's fine, and none of it would change for WSGI 2.0, except minor 
details of what wraps what.

Note, by the way, that as of Python 2.5, a generator can have 
try/finally and its close() method will be called when it finishes or 
is garbage collected.  So an app_iter implemented as a generator 
under 2.5 can just use with: or try/finally to handle cleanup -- and 
that applies equally to WSGI 1 and 2.



More information about the Web-SIG mailing list