On 18 March 2011 00:32, Greg Ewing <greg.ew...@canterbury.ac.nz> wrote: > Dag Sverre Seljebotn wrote: > >> def f(): >> with nogil: >> for ...: >> A >> if something_exceptional: >> with gil: >> raise Exception(...) >> B >> C > > If that's to be supported, the following really ought to be > supported as well: > > def f(): > with nogil: > try: > ... > with gil: > raise Exception() > finally: > ...do some cleanup... >
Why? I assume in his example the for loop was a Cython C for loop, not one that deals with Python objects. If you want to do cleanup you can catch the exception in the 'with gil:' block, or use try/finally in the 'with gil:' block or outside the 'with nogil:' block. Special-casing try/finally in nogil sections for only 'with gil:' sounds somewhat weird. On the other hand, it may be somewhat more convenient, and I think we could support it without having to acquire the GIL in the finally clause. I wouldn't be particularly opposed to that. > Greg > _______________________________________________ > cython-devel mailing list > cython-devel@python.org > http://mail.python.org/mailman/listinfo/cython-devel > _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel