GIL state needs to be released after finishing refnanny contexts
authorLisandro Dalcin <dalcinl@gmail.com>
Tue, 3 Feb 2009 17:39:04 +0000 (15:39 -0200)
committerLisandro Dalcin <dalcinl@gmail.com>
Tue, 3 Feb 2009 17:39:04 +0000 (15:39 -0200)
Cython/Compiler/Nodes.py

index 7664e0de7b3f0334cb9cd06d787ac79e615dddf4..0002cb218c0cbd378d9fbdba6c9ee9745df87e90 100644 (file)
@@ -1181,8 +1181,7 @@ class FuncDefNode(StatNode, BlockNode):
         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 @@ class FuncDefNode(StatNode, BlockNode):
                                              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)