From 7c3e51baf53c902f357d560bf58cf761c0b406d6 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 18 Aug 2026 11:23:13 +0100 Subject: [PATCH 1/2] Release GIL between calls to ndiCommand. --- ndicapimodule.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ndicapimodule.cxx b/ndicapimodule.cxx index fc1613d..3330d0c 100644 --- a/ndicapimodule.cxx +++ b/ndicapimodule.cxx @@ -752,11 +752,18 @@ static PyObject* Py_ndiCommand(PyObject* module, PyObject* args) return NULL; } - result = ndiCommand(pol, "%s", PyString_AsString(newstring)); + const char* cmd_cstr = PyString_AsString(newstring); + // Assumes caller manages threads. + Py_BEGIN_ALLOW_THREADS + result = ndiCommand(pol, "%s", cmd_cstr); + Py_END_ALLOW_THREADS } else { + // Assumes caller manages threads. + Py_BEGIN_ALLOW_THREADS result = ndiCommand(pol, NULL); + Py_END_ALLOW_THREADS } if (newstring != NULL) From ae25f2195c093bd54c0d04d2d588087b2ea59382 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 18 Aug 2026 11:23:36 +0100 Subject: [PATCH 2/2] Decreaase reference count on initial and remainder variables, as per other if blocks. --- ndicapimodule.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ndicapimodule.cxx b/ndicapimodule.cxx index 3330d0c..99ce408 100644 --- a/ndicapimodule.cxx +++ b/ndicapimodule.cxx @@ -760,6 +760,8 @@ static PyObject* Py_ndiCommand(PyObject* module, PyObject* args) } else { + Py_DECREF(initial); + Py_DECREF(remainder); // Assumes caller manages threads. Py_BEGIN_ALLOW_THREADS result = ndiCommand(pol, NULL);