How to run more than one instance of the Python interpreter in one process?

Syver Enstad syver at NOSPAMcyberwatcher.com
Sun Jan 7 19:13:49 EST 2001


"Tim Peters" <tim.one at home.com> wrote in message
news:mailman.978862627.7187.python-list at python.org...
> [Syver Enstad]
> > I am fiddling around with embedding Python in C/C++ and am trying
> > to run one interpreter per thread. I've tried using the
> > Py_NewInterpreter and Py_EndInterpreter for each thread but it
> > doesn't seem to be enough because I trigger access violations in
> > the interpreter so I am obviously missing a couple of things. Are
> > there any examples on how to do these kinds of things other than
> > the very sparse code in the demo folder of the source distribution.
>
> None that I've ever seen, or heard of.  Py_{New,End}Interpreter appeared
to
> have been added during a brief bout of Tcl Envy, and neglected thereafter.
> The natural place to talk about this is the Python Thread-SIG:

Thanks for answering Tim, but I don't really know if I need to use these
functions, what I need is how to run different python "applications" from
the same process. When I say applications I mean like for instance
PyRun_SimpleFile. These applications must not share things like sys.stdout
for instance because I am going to assign it to different objects for each
thread. Does these requirements mandate using something like
Py_NewInterpreter or can it be achieved in other ways.

NB. This is my first shot at using the Python C interface so there are
probably obvious things I haven't grok'ed yet, but I know C++ well.





More information about the Python-list mailing list