Lisandro Dalcin wrote:
> >> > 3/ restore the thread in the catch clause:
> >> > try {foo();} catch(...) { Py_BLOCK_THREADS __Pyx_CppExn2PyErr();
> > {__pyx_filename =
> >> __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L6;}}
> >> > }
> >> > /*finally:*/ {
> >> > int __pyx_why;
> >> > Py_BLOCK_THREADS // <<<<<<<<<<<<<<<<
> >> > __pyx_why = 0; goto __pyx_L7;
> >> > __pyx_L6: __pyx_why = 4; goto __pyx_L7;
> >> > __pyx_L7:;
> >> > switch (__pyx_why) {
> >> > case 4: goto __pyx_L1_error;
> >> > }
> >> > }
> >> > }
> >> >
> >>
> >> And this one looks bad, I think you need: Py_BLOCK_THREADS
> >> __Pyx_CppExn2PyErr(); Py_UNBLOCK_THREADS .. Am I right?
> >>
> A last thing: in my previous mail I commented about fixing you
> solution (3) like this:
>
> Py_BLOCK_THREADS
> __Pyx_CppExn2PyErr();
> Py_UNBLOCK_THREADS
>
> Is that right? Take into account that the /*finally:*/ block does
> Py_BLOCK_THREADS...
>
> If you can confirm that this works, I think you solution (3) with my
> fix (in case it is fine) is be better option, right?
Yes it works fine.
It's a bit less efficient than what I proposed, as, when an error occurs:
- it restores the thread context before Pyx_CppExn2PyErr(),
- saves the thread context after Pyx_CppExn2PyErr(),
- restores it in the /*finally:*/ block.
whereas what I proposed only restores once the context (before
Pyx_CppExn2PyErr(), skipped in the /*finally:*/ block).
But do we have to really care of performance when an error occurs?
Stephane
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev