[python-win32] C++ thread cannot acquire GIL
Brad Johnson
Brad.Johnson at ballardtech.com
Fri Nov 9 00:09:58 CET 2007
Brad Johnson <Brad.Johnson <at> ballardtech.com> writes:
>
> I am embedding a Python interpreter in a C++ app for Windows.
>
> The main thread in my application calls PyEval_InitThreads();
>
> At some point, the main thread creates a new thread to do some concurrent work
> using the Python interpreter.
>
> The trouble is that in my worker thread I am never able to complete the call
> PyEval_AcquireLock(), since something else must be holding the GIL (Python gets
> stuck in the WaitForSingleObject call)
>
> I cannot figure out what is holding the GIL, and believe me I've looked. Any
> debugging tips or glaring errors in my methodology?
>
> Thanks!
>
Just a follow-up, I've found a solution to this problem. Apparently, I was
running into a known bug with the Python C API reported here
http://bugs.python.org/issue1720250. The workaround is also posted here.
I hope this is helpful for posterity that may run into this in the future.
More information about the python-win32
mailing list