pthreads in C++ with embedded Python
Jason Tackaberry
tack at urandom.ca
Wed Jun 8 19:25:18 EDT 2011
On 11-06-08 06:28 PM, Tom Brown wrote:
> I found that PyEval_ReleaseLock() was necessary to keep the program
> from hanging. The lock() and unlock() methods were used in a previous
> attempt to lock/unlock the GIL.
I just tried your example code and indeed it segfaults as is, but works
fine for me when I comment out PyEval_ReleaseLock(). Perhaps this was
just a red herring, not actually solving your deadlock problem
properly? (That is, replacing one problem with another.)
> I kept banging at this and finally gave up on the GIL. I used a mutex
> instead. This allowed me to get rid of the Python API calls that dealt
> with the GIL. It works great in the test program. I'll find out how
> well it performs in the real program.
I suppose this could theoretically work in your specific example, but if
the Python module you're calling out to spawns threads you're screwed. :)
Cheers,
Jason.
More information about the Python-list
mailing list