Embedding: many interpreters OR one interpreter with many thread states ?

A

adsheehan

Hi,

Does anyone know the reasoning or pros/cons for either (in a
multi-threaded C++ app):

- creating many sub-interpreters (Py_NewInterpreter) with a thread
state each

Or

- creating one interpreter with many thread states (PyThreadState_New)


When do I choose one approach over the other and why ?

Thanks

Alan
 
G

Greg Ewing

- creating many sub-interpreters (Py_NewInterpreter) with a thread
state each

Or

- creating one interpreter with many thread states (PyThreadState_New)

My understanding is that using multiple interpeters isn't
really supported properly, despite there being apparent
support in the API. So I suggest using a single interpeter
with multiple threads.
 
F

flyingfred0

Of course, with multiple threads in one process, it's important to know
about the dreaded global interpreter lock (GIL) --
http://docs.python.org/api/threads.html

With one instance of the interpreter, only one Python thread will be
running at a time, no matter how many CPUs you have in the system.
 
G

grahamd

Greg said:
My understanding is that using multiple interpeters isn't
really supported properly, despite there being apparent
support in the API. So I suggest using a single interpeter
with multiple threads.

Huh. Mod_python uses multiple interpreters and within each
interpreter could be running multiple threads at one time
corresponding to different incoming HTTP requests.

It hasn't helped though that a bug was introduced in Python
2.3.5/4.0 which has been causing grief for some users creating
additional threads from within Python code itself. :-(


http://sourceforge.net/tracker/index.php?func=detail&aid=1163563&group_id=5470&atid=105470
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top