Digging deeper into the code, it appears to me that if I am using the PythonInterpreter in separate threads, I should have a new system state for each instance that is in a separate thread.



On Wed, Mar 10, 2010 at 9:28 AM, Santosh Tiwari <tiwaris@gmail.com> wrote:
So, it is generally a good idea to always create a new PySystemState and pass it to the constructor when creating a new instance of PythonInterpreter if we want the two instances to be completely independent. Am I right?

Can somebody approve or disapprove of my statement?


On Wed, Mar 10, 2010 at 9:27 AM, Santosh Tiwari <tiwaris@gmail.com> wrote:
So, it is generally a good idea to always create a new PySystemState and pass it to the constructor when creating a new instance of PythonInterpreter if we want the two instances to be completely independent.




On Wed, Mar 10, 2010 at 6:05 AM, <john.m.baker@nomura.com> wrote:
Right.  I had previously created a PythonInterpreter and need to create
a new one with a separate state for each stdout stream:

        PythonInterpreter.initialize(System.getProperties(), null, new
String[0]);
        PySystemState systemState = new PySystemState();
        pi = new PythonInterpreter(null, systemState);
        pi.setOut(outputStream);
        pi.setErr(outputStream);

I think PythonInterpreter could be improved by making that more obvious,
or by creating two versions of it - one which uses a 'shared state' and
another which creates a new PySystemState each time it's constructed.





--
Santosh Tiwari
tiwaris@gmail.com



--
Santosh Tiwari
tiwaris@gmail.com