Thursday, 24 February 2022

How to release GIL after Py_Initialize?

I am trying to embed python in a GUI application, and so I have a the python interpreter initialized in the main thread of the application, and I may launch python scripts from another one.

I read about PyGILState_Ensure and PyGILState_Release, and I put them around my code which launch python script in my subthread. But the call is blocking, and my code is never run.

It seems that my main thread is not releasing the GIL (checked with PyGILState). The GIL initialization is now done in Py_Initialize, and lot of old doc talk about PyEval_InitThreads and other now deprecated functions.

So with a modern python, how do we release a thread from the GIL after Py_Initialize ?



from How to release GIL after Py_Initialize?

No comments:

Post a Comment