15.8 C和Python中的线程混用
问题
解决方案
#include <Python.h>
//...
if (!PyEval_ThreadsInitialized()) {
PyEval_InitThreads();
}
//...//...
/* Make sure we own the GIL */
PyGILState_STATE state = PyGILState_Ensure();
/* Use functions in the interpreter */
//...
/* Restore previous GIL state and return */
PyGILState_Release(state);
//...讨论
Last updated