PyGILState_Ensure() deadlocks, why?

Barry barry at barrys-emacs.org
Sun Jul 7 18:21:55 EDT 2024



> On 7 Jul 2024, at 22:09, Tomas Ukkonen via Python-list <python-list at python.org> wrote:
> 
>     Py_Initialize();

You also need to tell python to init threading.
I think you are missing more python setup code before you can use threads.
Also i think you need to tell python that your thread wants to call into python.
But I an not near my dev system to research this for you.

I have code to use python from C++ in my pysvn project.
See the code starting a line 354 in https://sourceforge.net/p/pysvn/code/HEAD/tree/trunk/pysvn/Extension/Source/pysvn.cpp
That saves the thread state and restores it.

But in my case python creates the threads and I release and acquire the GIL.

Barry





More information about the Python-list mailing list