diff --git a/ndicapimodule.cxx b/ndicapimodule.cxx index fc1613d..99ce408 100644 --- a/ndicapimodule.cxx +++ b/ndicapimodule.cxx @@ -752,11 +752,20 @@ 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 { + Py_DECREF(initial); + Py_DECREF(remainder); + // Assumes caller manages threads. + Py_BEGIN_ALLOW_THREADS result = ndiCommand(pol, NULL); + Py_END_ALLOW_THREADS } if (newstring != NULL)