[libpeas] Ensure we hold the GIL when calling into python extensions.
- From: Steve Frécinaux <sfre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas] Ensure we hold the GIL when calling into python extensions.
- Date: Sun, 6 Mar 2011 15:02:30 +0000 (UTC)
commit 4dc3060ab6fbdbf0b17ac7f4770cb98da97e940b
Author: Steve Frécinaux <code istique net>
Date: Sun Mar 6 15:58:52 2011 +0100
Ensure we hold the GIL when calling into python extensions.
This fixes a crash in python 3.0, despite it doesn't seem to affect
older python versions at all.
loaders/python/peas-extension-python.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/loaders/python/peas-extension-python.c b/loaders/python/peas-extension-python.c
index daa0097..5277742 100644
--- a/loaders/python/peas-extension-python.c
+++ b/loaders/python/peas-extension-python.c
@@ -48,14 +48,20 @@ peas_extension_python_call (PeasExtension *exten,
GIArgument *retval)
{
PeasExtensionPython *pyexten = PEAS_EXTENSION_PYTHON (exten);
+ PyGILState_STATE state;
GObject *instance;
+ gboolean success;
if (gtype == G_TYPE_INVALID)
gtype = peas_extension_get_extension_type (exten);
+ state = pyg_gil_state_ensure ();
+
instance = pygobject_get (pyexten->instance);
+ success = peas_method_apply (instance, gtype, method_name, args, retval);
- return peas_method_apply (instance, gtype, method_name, args, retval);
+ pyg_gil_state_release (state);
+ return success;
}
static void
@@ -65,8 +71,12 @@ peas_extension_python_dispose (GObject *object)
if (pyexten->instance)
{
+ PyGILState_STATE state = pyg_gil_state_ensure ();
+
Py_DECREF (pyexten->instance);
pyexten->instance = NULL;
+
+ pyg_gil_state_release (state);
}
G_OBJECT_CLASS (peas_extension_python_parent_class)->dispose (object);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]