Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Embedding: many interpreters OR one interpreter with many thread states ?

Reply
Thread Tools

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

 
 
adsheehan@eircom.net
Guest
Posts: n/a
 
      06-08-2005

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

 
Reply With Quote
 
 
 
 
Greg Ewing
Guest
Posts: n/a
 
      06-09-2005
wrote:

> - 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.

--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
 
Reply With Quote
 
 
 
 
flyingfred0
Guest
Posts: n/a
 
      06-10-2005
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.


Greg Ewing wrote:
> wrote:
>
>> - 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.
>

 
Reply With Quote
 
grahamd@dscpl.com.au
Guest
Posts: n/a
 
      06-10-2005

Greg Ewing wrote:
> wrote:
>
> > - 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.


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...70&atid=105470

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
fsm 4 states only one state displaying other 3 no.. harrama Software 0 12-15-2011 12:34 PM
using python interpreters per thread in C++ program grbgooglefan Python 24 09-08-2009 07:37 AM
Python embedded interpreter: how to initialize the interpreter ? ycollet@freesurf.fr Python 3 01-03-2007 01:00 AM
one producer thread, one consumer thread: mutex needed? smith4894@excite.com C Programming 3 09-19-2005 05:03 PM
Multiple Interpreters In a Single Thread bmatt Python 2 09-29-2004 11:07 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57