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.
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
PySystemState systemState = new PySystemState();
pi = new PythonInterpreter(null, systemState);
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.