123 wlpha added the comment:
Usually in the python extension, only the python function needs to be written
between Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW THREADS, but the c callback
function needs PyGILState_Ensure and PyGILState_Release, but PyGILState_Releas
cannot release gil correctly
New submission from 123 wlpha :
PyGILState_Release does not really release gil, causing the next
PyGILState_Ensure deadlock, now you need to call if (PyGILState_Check () > 0)
{PyEval_SaveThread ();}
```
auto gil = PyGILState_Ensure();
// call c api
PyGILState_Release (gil);