Graham Dumpleton <graham.dumple...@gmail.com> added the comment:

The PyGILState_Ensure() function is only for when working with the main 
interpreter. These external threads are not calling into the main interpreter.

Because they are external threads, calling PyGILState_Ensure() and then 
PyGILState_Release() will cause a thread state to be created for the main 
interpreter, but it will also be destroyed on the PyGILState_Release().

The only way to avoid that situation and ensure that the thread state for the 
main interpreter is therefore maintained would be to call PyGILState_Ensure() 
and then call PyThreadState_Swap() to change to thread state for the sub 
interpreter. Problem is that you aren't supposed to use PyThreadState_Swap() 
any more and recollect that newer Python 3.X even prohibits it in some way 
through some checks.

So, the documentation you quote is only to do with the main interpreter and is 
not how things work for sub interpreters.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13156>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to