On 23 September 2010 06:42, Stephane DROUARD <[email protected]> wrote: > Lisandro Dalcin wrote: > >> Ah! now I see.. so you are removing the Py_BLOCK_THREADS from finally >> block and moving it up to the try block. Looks good... > > OK. > > > I checked other except clauses and propose a solution to fix them. > > 1/ void foo() nogil except +MemoryError > > Generated: > try {foo();} catch(...) { try { throw; } catch(const std::exception& > exn) { PyErr_SetString(__pyx_builtin_MemoryError, exn.what()); } catch(...) { > PyErr_SetNone(__pyx_builtin_MemoryError); }; {__pyx_filename = __pyx_f[0]; > __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L6;}} > > Proposed fix: > try {foo();} catch(...) { Py_BLOCK_THREADS try { throw; } catch(const > std::exception& exn) { PyErr_SetString(__pyx_builtin_MemoryError, > exn.what()); } catch(...) { PyErr_SetNone(__pyx_builtin_MemoryError); }; > {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; > goto __pyx_L6;}} > > > 2/ void foo() nogil except * > > Generated: > foo(); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; > __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L6;} > > Proposed fix (need to restore the context before checking and save again in > case there is no error): > foo(); Py_BLOCK_THREADS if (unlikely(PyErr_Occurred())) {__pyx_filename > = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L6;} > Py_UNBLOCK_THREADS > > > 3/ int foo() nogil except -1 > > Generated: > __pyx_t_1 = foo(); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = > __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L6;} > > Proposed fix: > __pyx_t_1 = foo(); if (unlikely(__pyx_t_1 == -1)) { Py_BLOCK_THREADS > __pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto > __pyx_L6;} > > > 4/ int foo() nogil except? -1 > > Generated: > __pyx_t_1 = foo(); if (unlikely(__pyx_t_1 == -1 && PyErr_Occurred())) > {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; > goto __pyx_L6;} > > Proposed fix: > __pyx_t_1 = foo(); if (unlikely(__pyx_t_1 == -1)) { Py_BLOCK_THREADS if > (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; > __pyx_clineno = __LINE__; goto __pyx_L6;} Py_UNBLOCK_THREADS } > > > Cheers,
Any chance you could help us by writing a comprehensive testcase to speedup the resolution of this issue? -- Lisandro Dalcin --------------- CIMEC (INTEC/CONICET-UNL) Predio CONICET-Santa Fe Colectora RN 168 Km 472, Paraje El Pozo Tel: +54-342-4511594 (ext 1011) Tel/Fax: +54-342-4511169 _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
