Thanks Alan, that was really the case. However, that brings up another issue:

I actually used to instantiate the interpreter with

pyint = new PythonInterpreter(null, new PySystemState());

But, when I discovered that the code below fails to convert a Java object ("event" in this case), I, almost by trial&error found out that if I instantiate the interpreter with pyint = new PythonInterpreter(), the Py.java2py() method actually works.

PyObject pyClass = pyint.get("ClassName");
PyObject eventEntryPointCallable = pyClass.__getattr__("event_entry_point");
eventEntryPointCallable.__call__(new PyString(eventType), Py.java2py(event));

Oddly, the call to eventEntryPointCallable.__call__() silently fails without any error whatsoever. The Jython function (a static method in Python class) is just not called.

The docs on Py.java2py() say that it "Uses the PyObjectAdapter passed to PySystemState.initialize() to turn o into a PyObject." Well, I don't pass any PyObjectAdapter to the PySystemState. So, perhaps I have to set up the PySystemState instance a bit, so that the Py.java2py call works, but I have no idea where do I get a nice general-purpose PyObjectAdapter that will do the job. I know it must exist somewhere, because the event handler is nicely triggered, if the interpreter is instantiated with simple new PythonInterpreter().


On Thu, Oct 10, 2013 at 8:08 PM, Alan Kennedy <> wrote:
The interpreters are probably sharing the same PySystemState, which is where the output stream is set.

If you want them to have separate system states, use the constructor that allows you to specify a different PySystemState for each intepreter.,%20org.python.core.PySystemState%29


On Wed, Oct 9, 2013 at 11:19 PM, Pāvils Jurjāns <> wrote:
I have a server environment where there are multiple Jython interpreter instances. Since I need to distinguish output coming from each, I've made my custom OutputStream class.

PyFile myOut = new PyFile(new PyscripterOutputStream(this));
myOut.encoding = "UTF-8";

However, I've found out that each next call to pyint.setOut() overrides the output streams of the previously initialized interpreter instances. As if that would be a global setting, not an individual one.

Any ideas what's going on?

October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
Jython-users mailing list