diff --git a/libsrc/general/ngpython.hpp b/libsrc/general/ngpython.hpp index e0980d85..c3931215 100644 --- a/libsrc/general/ngpython.hpp +++ b/libsrc/general/ngpython.hpp @@ -1,5 +1,17 @@ #ifdef NG_PYTHON +// BEGIN EVIL HACK: Patch PyThread_get_key_value inside pybind11 to avoid deadlocks +// see https://github.com/pybind/pybind11/pull/1211 +#include +#include +namespace pybind11 { + inline void * PyThread_get_key_value(int state) { + PyThreadState *tstate = (PyThreadState *) ::PyThread_get_key_value(state); + if (!tstate) tstate = PyGILState_GetThisThreadState(); + return tstate; + } +} +// END EVIL HACK #include #include namespace py = pybind11;