]> sigrok.org Git - libsigrokdecode.git/blobdiff - session.c
Acquire/release the Python GIL where needed to avoid threading issues.
[libsigrokdecode.git] / session.c
index 14484504ce2fe9974cf707e14d822693b8331b67..0c1ef8205634512f1d7de78a2e0d80f5ff2e271c 100644 (file)
--- a/session.c
+++ b/session.c
@@ -131,11 +131,14 @@ static int srd_inst_send_meta(struct srd_decoder_inst *di, int key,
        GSList *l;
        struct srd_decoder_inst *next_di;
        int ret;
+       PyGILState_STATE gstate;
 
        if (key != SRD_CONF_SAMPLERATE)
                /* This is the only key we pass on to the decoder for now. */
                return SRD_OK;
 
+       gstate = PyGILState_Ensure();
+
        if (PyObject_HasAttrString(di->py_inst, "metadata")) {
                py_ret = PyObject_CallMethod(di->py_inst, "metadata", "lK",
                                (long)SRD_CONF_SAMPLERATE,
@@ -143,6 +146,8 @@ static int srd_inst_send_meta(struct srd_decoder_inst *di, int key,
                Py_XDECREF(py_ret);
        }
 
+       PyGILState_Release(gstate);
+
        /* Push metadata to all the PDs stacked on top of this one. */
        for (l = di->next_di; l; l = l->next) {
                next_di = l->data;