[pygobject] Release the lock when potentially invoking Python code.



commit 433ee2aa029a1482961f478252a06492bd3498e6
Author: Sjoerd Simons <sjoerd simons collabora co uk>
Date:   Tue Jun 15 11:42:28 2010 +0200

    Release the lock when potentially invoking Python code.
    
    * gobject/pygobject.c: Release GIL lock when retrieving properties
    and when clearing a PyGObject.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=530935

 gobject/pygobject.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/gobject/pygobject.c b/gobject/pygobject.c
index 4b6fe6f..e017d6c 100644
--- a/gobject/pygobject.c
+++ b/gobject/pygobject.c
@@ -269,7 +269,9 @@ PyGProps_getattro(PyGProps *self, PyObject *attr)
     }
     
     g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
+    pyg_begin_allow_threads;
     g_object_get_property(self->pygobject->obj, attr_name, &value);
+    pyg_end_allow_threads;
     ret = pyg_param_gvalue_as_pyobject(&value, TRUE, pspec);
     g_value_unset(&value);
     
@@ -1048,8 +1050,11 @@ pygobject_clear(PyGObject *self)
         if (self->inst_dict) {
             g_object_remove_toggle_ref(self->obj, pyg_toggle_notify, self);
             self->private_flags.flags &= ~PYGOBJECT_USING_TOGGLE_REF;
-        } else
+        } else {
+            pyg_begin_allow_threads;
             g_object_unref(self->obj);
+            pyg_end_allow_threads;
+        }
         self->obj = NULL;
     }
     Py_CLEAR(self->inst_dict);
@@ -1179,7 +1184,9 @@ pygobject_get_property(PyGObject *self, PyObject *args)
 	return NULL;
     }
     g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
+    pyg_begin_allow_threads;
     g_object_get_property(self->obj, param_name, &value);
+    pyg_end_allow_threads;
     ret = pyg_param_gvalue_as_pyobject(&value, TRUE, pspec);
     g_value_unset(&value);
     return ret;
@@ -1229,7 +1236,9 @@ pygobject_get_properties(PyGObject *self, PyObject *args)
         }
         g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
 
+        pyg_begin_allow_threads;
         g_object_get_property(self->obj, property_name, &value);
+        pyg_end_allow_threads;
 
         item = pyg_value_as_pyobject(&value, TRUE);
         PyTuple_SetItem(tuple, i, item);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]