using python interpreters per thread in C++ program

ganesh ganeshborse at gmail.com
Mon Sep 7 22:22:17 EDT 2009


My application is a TCP server having multiple client connectons. C++
PTHREADS are for each connected socket and the message received on the
socket is evaluated by python functions.
If I use only one process level python interpreter, then every thread
has to lock the GIL & so blocking the other threads from executing the
python code even if it is not the same python function that locking
thread is calling.

-- That's why I tried using python interpreters per thread. But that
also required GIL locking & so cannot be used.

-- I cannot use python threads inside the Pyton intrepreter because
then I will have to have some mechanism for communiaction between C++
Pthreads with these python threads.

I think there is no way that we can achieve this because of the GIL
being a process level state. Least I can do is have one python
interpreter initialized in main thread and lock the GIL in every
thread for python calls.



More information about the Python-list mailing list