문제

I have a python program that calls into a c++ library, which wishes to release all the python locks so that other python threads can run.

Using PyEval_SaveThread and PyEval_ReleaseThread I get errors that the thread state is NULL:

Fatal Python error: PyEval_SaveThread: NULL tstate

However, the lower-level function seem to accept the NULL state happily:

PyThreadState *s;
s = PyThreadState_Swap(NULL);
// (now s = 0)
PyEval_ReleaseLock();

// ....

PyEval_AcquireLock();
PyThreadState_Swap(s);

// everything seems to be just fine :)
도움이 되었습니까?

해결책

Answer: no, it is never meant to be NULL (if it is, it's a fatal error). Turned out this was because I was linking against two different versions of python, one via boost_python, and the other directly.

Top Tip: use ldd or otool -L to check your library dependencies when funny stuff happens ;)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top