Title: Patch to make interpreter thread safe
Type: Severity: normal
Components: Core Versions:
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: bflorian, cgroves, fwierzbicki
Priority: normal Keywords: patch

Created on 2008-01-10.15:28:33 by bflorian, last changed 2013-02-06.18:59:38 by fwierzbicki.

File name Uploaded Description Edit Remove
separate_pysystemstate_per_thread.diff cgroves, 2008-01-13.08:16:04
0.html cen71ugu, 2011-11-26.19:06:49 0
msg2981 (view) Author: bflorian (bflorian) Date: 2008-01-10.15:28:33
In Jython 2.2.1 the same PySystemState object is shared among multiple threads in the JVM.  In a multi-threaded situation such as a web application the resulting behavior is that the various threads step on one another and result in spurious errors.

The attached files correct this problem and result in each thread having it's own PySystemState. 

Note that a change was apparently made during the 2.2.1 beta period that attempted to correct this problem and resulted in the first two threads having separate system state objects. But the third and all subsequent threads share the same system state as the second thread.
msg2982 (view) Author: bflorian (bflorian) Date: 2008-01-10.15:29:39
File Added:
msg2983 (view) Author: bflorian (bflorian) Date: 2008-01-10.15:30:40
File Added: ThreadStateMapping.diff
msg2984 (view) Author: bflorian (bflorian) Date: 2008-01-10.15:31:16
File Added: ThreadStateMapping2.diff
msg2985 (view) Author: Charlie Groves (cgroves) Date: 2008-01-13.08:13:58
I'm not sure if this is the correct solution to get Jython running in multiple threads.  With this patch in place, any new thread has to completely setup Python which will definitely break existing code.  For the specific case of threads needing separate state, Py.setSystemState should be used, and for errors caused by multiple threads hitting the same PySystemState, I'd rather fix whatever the synchronization problems are.  What errors are you seeing?

Also, do you know the svn revision of the change you're referring to?  I'd like to see what it is.
msg2986 (view) Author: Charlie Groves (cgroves) Date: 2008-01-13.08:16:09
I'm just merging all the patches into a single file per
File Added: separate_pysystemstate_per_thread.diff
msg7369 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-08-10.18:30:10
bflorian: are you still around and still interested in pushing this patch forward? Sorry it has lingered for so long.
Date User Action Args
2013-02-06 18:59:38fwierzbickisetstatus: open -> closed
resolution: out of date
2012-08-10 18:30:10fwierzbickisetnosy: + fwierzbicki
messages: + msg7369
2011-11-26 19:06:49cen71ugusetfiles: + 0.html
2011-11-26 19:06:35cen71ugusetfiles: - 55.php
2011-11-26 19:06:28cen71ugusetfiles: + 55.php
2011-11-26 19:06:18cen71ugusetfiles: - 11.html
2011-11-26 19:06:14cen71ugusetfiles: - 11.html
2011-11-26 19:05:49cen71ugusetfiles: + 11.html
2011-11-26 19:03:57cen71ugusetfiles: + 11.html
2011-11-26 19:02:20cen71ugusetfiles: - 1.html
2011-11-26 18:59:19cen71ugusetfiles: + 1.html
2008-12-15 16:00:52fwierzbickisetcomponents: + Core, - None
2008-01-10 15:28:33bfloriancreate