15.7 从C扩展中释放全局锁
问题
解决方案
#include "Python.h"
//...
PyObject *pyfunc(PyObject *self, PyObject *args) {
//...
Py_BEGIN_ALLOW_THREADS
// Threaded C code. Must not use Python API functions
//...
Py_END_ALLOW_THREADS
//...
return result;
}讨论
Last updated