[python] Patch pybind11 function to avoid deadlocks

see https://github.com/pybind/pybind11/pull/1211
This commit is contained in:
Matthias Hochsteger 2018-06-29 16:22:21 +02:00
parent 95efdd212d
commit ec3051815c

View File

@ -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 <Python.h>
#include <pythread.h>
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 <pybind11/pybind11.h>
#include <pybind11/operators.h>
namespace py = pybind11;