[pygobject/benzea/tmp: 5/7] gimodule: Expose PyOS_setsig for asyncio eventloop




commit 03a4b53a7c1f1460ce5900f563903293ceea8e13
Author: Benjamin Berg <bberg redhat com>
Date:   Wed Oct 27 15:00:39 2021 +0200

    gimodule: Expose PyOS_setsig for asyncio eventloop

 gi/_ossighelper.py |  1 +
 gi/gimodule.c      | 13 +++++++++++++
 2 files changed, 14 insertions(+)
---
diff --git a/gi/_ossighelper.py b/gi/_ossighelper.py
index fba24e6d..fd1b4499 100644
--- a/gi/_ossighelper.py
+++ b/gi/_ossighelper.py
@@ -127,6 +127,7 @@ def wakeup_on_signal():
 
 
 PyOS_getsig = _gi.pyos_getsig
+PyOS_setsig = _gi.pyos_setsig
 
 # We save the signal pointer so we can detect if glib has changed the
 # signal handler behind Python's back (GLib.unix_signal_add)
diff --git a/gi/gimodule.c b/gi/gimodule.c
index 3c9859ba..6a90ce7c 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -2271,6 +2271,18 @@ _wrap_pyig_pyos_getsig (PyObject *self, PyObject *args)
     return PyLong_FromVoidPtr ((void *)(PyOS_getsig (sig_num)));
 }
 
+static PyObject *
+_wrap_pyig_pyos_setsig (PyObject *self, PyObject *args)
+{
+    int sig_num;
+    PyObject *sig_handler;
+
+    if (!PyArg_ParseTuple (args, "iO!:pyos_setsig", &sig_num, &PyLong_Type, &sig_handler))
+        return NULL;
+
+    return PyLong_FromVoidPtr ((void *)(PyOS_setsig (sig_num, (PyOS_sighandler_t) PyLong_AsVoidPtr 
(sig_handler))));
+}
+
 static PyObject *
 _wrap_pygobject_new_full (PyObject *self, PyObject *args)
 {
@@ -2309,6 +2321,7 @@ static PyMethodDef _gi_functions[] = {
     { "variant_type_from_string", (PyCFunction) _wrap_pyg_variant_type_from_string, METH_VARARGS },
     { "source_new", (PyCFunction) pygi_source_new, METH_NOARGS },
     { "pyos_getsig", (PyCFunction) _wrap_pyig_pyos_getsig, METH_VARARGS },
+    { "pyos_setsig", (PyCFunction) _wrap_pyig_pyos_setsig, METH_VARARGS },
     { "source_set_callback", (PyCFunction) pygi_source_set_callback, METH_VARARGS },
     { "io_channel_read", (PyCFunction) pyg_channel_read, METH_VARARGS },
     { "require_foreign", (PyCFunction) pygi_require_foreign, METH_VARARGS | METH_KEYWORDS },


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