[C++-sig] Multithreaded Python embedding
Niall Douglas
s_sourceforge at nedprod.com
Mon Apr 23 19:23:38 CEST 2007
On 21 Apr 2007 at 23:12, Michael Gauckler wrote:
> I'd like to write a multi-threaded C++ program where each thread contains
> its own python interpreter.
>
> The code should act as a servant in a distributed environment and several
> (#threads) requests are handled in the (separate) interpreters running
> concurrently (on several CPUs).
>
> Is it possible to do this? What's the best way to do it? I read about the
> issues of the GIL, but as I understand it, this only applies to
> multi-threading within a single python interpreter instance.
Unless something substantial has changed in recent Python versions,
there is still one GIL for the entire of Python. This reduces
concurrency somewhat, but not fatally.
Check this list's archives for how to patch Boost.Python to unlock
the GIL while in C++ code.
Cheers,
Niall
More information about the Cplusplus-sig
mailing list