Barnabas Wolf wrote:
>I'm trying to add Python scripting capabilities to an existing Java
>application. I would need to be able to execute scripts fully
>independently in different threads. I've attempted this by creating
>an instance of PythonInterpreter in each of the threads. This approach
>appears to work, but not perfectly. For example, all interpreters
>share the same IO streams -- calling setOut(), setErr(), etc. on any
>of the interpreters will redirect *all* of the interpreters to the
>new stream. This particular problem is not a complete show stopper,
>but it makes me worry about how independent the interpreters really
>are.
I have also tried to use multiple interpreters in different threads.
That was a while back using JPython 1.1. At that time, the different
threads corrupted each other in short order. I have not tried again
recently, but after looking inside the jython code, I see that quite a
lot of state information is stored statically, which leads me to believe
that jython was not designed for multithreaded used in this way. If so,
that is a shame, as this would be very useful.
Perhaps someone knows otherwise and can tell us what we are doing wrong?
-Paul
--
Paul Giotta
Software Architect
pau...@so...
Office: +41 1 445 2370 | Fax: +41 1 445 2372 | Mobile: +41 76 389 1180
Technoparkstr.1, 8005 Zurich, Switzerland | http://www.softwired-inc.com
* e2e Java Messaging, Pure and Simple. *
|