How can I check whether a thread currently holds the GIL?
问题 I tried to find a function that tells me whether the current thread has the global interpreter lock or not. The Python/C-API documentation does not seem to contain such a function. My current solution is to just acquire the lock using PyGILState_Ensure() before releasing it using PyEval_SaveThread to not try releasing a lock that wasn't acquired by the current thread. (btw. what does "issues a fatal error" mean?) Background of this question: I have a multithreaded application which embeds