[C++-SIG] Controlling python execution from C
Marcelo Kallmann
kallmann at lig.di.epfl.ch
Mon Nov 15 11:06:45 CET 1999
Hello,
Looking at the manuals, I saw that the function Py_NewInterpreter(), "simulates"
the creation of a new thread, so that different scripts would be interpreted
"pratically" in paralell by interpreting some bytecodes of each one from time to
time. There is even a method to say how many bytecodes to interpret in one
script (default=10) before changing to interpret the next script.
I tryed to test this feature from C calls, by playing with thread states,
interpreter states, run_string, etc, but with no success...
What I would like to do is to have n scripts ( char *script[n]; ), and be able
to run them in the same application loop, having something like :
while ( true )
{ for ( int i=0; i<n; i++ )
{ restore_python_thread_state ( i ); // would call python functions to
restore internal states, etc.
run_some_bytecodes_of_python_script ( script[i] ); // would not block
my loop, would not run all the script !
}
....
}
So, first of all, my question is : Is this possible to do ?
If so, can someone explain me, or send me some example code please.
Thank you all,
Marcelo K.
LIG - EPFL
More information about the Cplusplus-sig
mailing list