Multiple Interpreters In a Single Thread

bmatt bsmatt at gmail.com
Thu Sep 23 10:52:18 EDT 2004


I am trying to support multiple interpreter instances within a single
main application thread. The reason I would like separate interpreters
is because objects in my system can be extended with python scripts
via a well defined interface (i.e. The onCreate script will be called
when the object is created).

So...Is it necessary to use multiple interpreters since each script I
import will be given its own module name and therefore the predefined
functions can be resolved using that module name?

If it is necessary then how is this accomplished? I have tried using
Py_NewInterpreter() but have been getting a strange crash (invalid
thread state).

Another concern I have is that I would like to be able to support
scripts defining their own application loop like functions. These
functions will need to be able to pause and wait for the next
application loop iteration before continuing. So...is there a way to
stop the interpreter ( via a call to an application defined function
like system.waitIteration() ), save the state of the interpreter and
continue processing when the application says it is ready?

I know these are kind of high level and vague questions but I am just
in the proof of concept and design phase and need to make sure some of
my ideas are feasible. Any information would be appreciated.

Thanks



More information about the Python-list mailing list