[Cython] review this fix for bad interaction of refnanny + 'with gil'

Lisandro Dalcin dalcinl at gmail.com
Tue Feb 3 18:06:10 CET 2009


After the patch below (plus some changes in refnanny.pyx, that's for
other mail), I get the full mpi4py testsuite pass....

Basically, the refnanny context needs to be finished BEFORE the GIL
state is released...

Could any of you tell me if this fix would be required at some other
place? I got a bit lost. ;-) ...

diff -r e35f20896675 Cython/Compiler/Nodes.py
--- a/Cython/Compiler/Nodes.py	Tue Feb 03 14:00:31 2009 -0200
+++ b/Cython/Compiler/Nodes.py	Tue Feb 03 14:49:10 2009 -0200
@@ -1181,8 +1181,7 @@
         for entry in lenv.arg_entries:
             if entry.type.is_pyobject and
lenv.control_flow.get_state((entry.name, 'source')) != 'arg':
                 code.put_var_decref(entry)
-        if acquire_gil:
-            code.putln("PyGILState_Release(_save);")
+
         # code.putln("/* TODO: decref scope object */")
         # ----- Return
         # This code is duplicated in ModuleNode.generate_module_init_func
@@ -1199,6 +1198,9 @@
                                              Naming.retval_cname,
                                              err_val)

+        if acquire_gil:
+            code.putln("PyGILState_Release(_save);")
+
         if not self.return_type.is_void:
             code.putln("return %s;" % Naming.retval_cname)




-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594


More information about the Cython-dev mailing list