Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7265

Re: pthreads in C++ with embedded Python

Date 2011-06-08 19:25 -0400
From Jason Tackaberry <tack@urandom.ca>
Subject Re: pthreads in C++ with embedded Python
References <BANLkTim6kOWDY4Hggcv9qXh224sqXFmsaA@mail.gmail.com> <4DEFE594.2030406@urandom.ca> <BANLkTinspOkm-qWSm9zAqUW1J_3ivV0NzA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.39.1307575632.11593.python-list@python.org> (permalink)

Show all headers | View raw


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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: pthreads in C++ with embedded Python Jason Tackaberry <tack@urandom.ca> - 2011-06-08 19:25 -0400

csiph-web