PyEval_CallObject and threads
Phlip
phlip_cpp at my-deja.com
Mon Mar 12 15:15:31 EST 2001
Tim Peters wrote:
> [Phlip]
>> My colleague came over and asked me to write this:
>>
>> "We got multiple C++ pthreads calling PyEval_CallObject. How threadsafe
>> is the Python API? A C++ module using Boost BPL creates multiple threads,
>> which then call back into Python. When two threads simultaneously call
>> PyEval_CallObject we go boom."
>>
>> I will now go examine his serialization primitives. But if anyone has any
>> better ideas...
>
> With very few exceptions, all calls to Python C API functions must be made
> while holding the global interpreter lock. The exceptions have mostly to
> do
> with a handful of functions related to initialization and shutdown. See
> the section "Thread State and the Global Interpreter Lock" in the Python/C
> API Reference Manual for details.
Further inspection reveals our architect(s) think we need to call Python
script asynchronously from multiple threads. By 'lock' we assume both you
and the section you cite mean 'block'. Isn't this what Stackless Python is
for?
--
Phlip phlip_cpp at my-deja.com
============== http://phlip.webjump.com ==============
-- Proud victim of the dreaded boomerang effect --
More information about the Python-list
mailing list