我将Python36嵌入到我的C ++适配器中。适配器将加载python插件,并为每个已加载的插件创建新的子解释器。但是,即使是最简单的示例,我也失败了。
Py_Initialize();
PyEval_InitThreads();
PyThreadState * pthreadState = Py_NewInterpreter();
assert(pthreadState == PyThreadState_GET());
PyObject * obj = PyImport_ImportModule("sys");
Py_DECREF(obj); // Py_EndInterpreter hangs if this is executed
Py_EndInterpreter(pthreadState);
呼叫Py_DECREF
会挂起Py_EndInterpreter
呼叫。任何帮助表示赞赏。
谢谢。