Author yocaba
Recipients yocaba
Date 2016-08-11.17:09:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
We are using Jython embedded in a Java application to evaluate Python scripts by using the PythonScriptEngine. For us, it is essential that the Python scripts can be evaluated in parallel within one Java Virtual Machine. We encountered an issue that doesn't allow this scenario: When we evaluate multiple Python scripts in parallel by multiple threads (with different instances of PythonScriptEngine), the standard output of the scripts get mixed up.

Attached a Java file demonstrating the issue:
Different scripts are evaluated by multiple threads in parallel with a new instance of PythonScriptEngine for each script evaluation. Each script prints a certain unique index multiple times. A Writer instance is injected in each PythonScriptEngine instance which checks the output of the script evaluated. Each Writer instance is instantiated with the index to expect.

Expected behavior: Each Writer instance receives only the expected index, means only the output of the Python script it is 'linked' with.

Observed behavior: Writer instances also receive indexes of "forgein" scripts.

(The test run and failed with Jython 2.5.2 and 2.7.0.)

Is there currently a way to make the script evaluation thread-safe?
Date User Action Args
2016-08-11 17:09:55yocabasetrecipients: + yocaba
2016-08-11 17:09:55yocabasetmessageid: <>
2016-08-11 17:09:55yocabalinkissue2513 messages
2016-08-11 17:09:54yocabacreate