Message10891

Author yocaba
Recipients yocaba
Date 2016-08-11.17:09:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1470935395.44.0.960761716174.issue2513@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2016-08-11 17:09:55yocabasetrecipients: + yocaba
2016-08-11 17:09:55yocabasetmessageid: <1470935395.44.0.960761716174.issue2513@psf.upfronthosting.co.za>
2016-08-11 17:09:55yocabalinkissue2513 messages
2016-08-11 17:09:54yocabacreate