[issue38680] PyGILState_Release does not release gil correctly, resulting in deadlock

2019-11-03 Thread 123 wlpha
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

[issue38680] PyGILState_Release does not release gil correctly, resulting in deadlock

2019-11-03 Thread 123 wlpha
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 (