Issue2465

classification
Title: no clear way to instantiate independent PythonInterpreters
Type: behaviour Severity: major
Components: Core Versions: Jython 2.7
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: amak, jason_s, jeff.allen, zyasoft
Priority: Keywords: thread-interpreter context

Created on 2016-02-10.18:45:44 by jason_s, last changed 2018-03-04.13:44:29 by jeff.allen.

Messages
msg10739 (view) Author: Jason Sachs (jason_s) Date: 2016-02-10.18:45:43
The ugly truth of the PythonInterpreter class, now that I have looked at the source, seems to be that by default it shares PySystemState objects between instances of PythonInterpreters. This means that having more than one PythonInterpreter won't share local variables, but it WILL share imports and sys.path and a bunch of other things.

If I truly want independent PythonInterpreter objects, I have to create my own PySystemState object for each interpreter. This is easy, but there is no function that helps setup the PySystemState object properly without relying on static mutable state. I'm looking at you, PySystemState.doInitialize() -- lots of goodies here but it acts upon the default system state and there is no way to do the same thing on an independent PySystemState object without duplicating lots of pieces of source code and trying to remove static mutable state. >:(
msg10740 (view) Author: Jim Baker (zyasoft) Date: 2016-02-10.18:57:35
So I did some refactoring PySystemState for 2.7, but I was unable to get rid of all the ugliness in doInitialize around static mutable state.

Maybe it's something we can completely re-address in Jython 3.x?

But having functionality to help do such PySystemState setup, as Jason suggests, is something we can definitely look at for 2.7.2. We can look at design ideas here for a clean API to manage PythonInterpreter/PySystemState lifecycle, then move to jython-dev for a final discussion.
msg11742 (view) Author: Jeff Allen (jeff.allen) Date: 2018-03-04.13:44:28
We definitely haven't taken that "look at design ideas here" as Jim invites us (meaning on this ticket, I think). However, jython-dev is a probably the better place from the start (once Sourceforge recovers) as everyone likely to care is subscribed to that.

I think this has interesting architectural implications and we're not likely to do the right thing in time for 2.7.2.
History
Date User Action Args
2018-03-04 13:44:29jeff.allensetkeywords: + thread-interpreter context
nosy: + jeff.allen
messages: + msg11742
milestone: Jython 2.7.2 ->
2016-02-12 17:27:56amaksetnosy: + amak
2016-02-10 18:57:36zyasoftsetnosy: + zyasoft
messages: + msg10740
milestone: Jython 2.7.2
2016-02-10 18:45:44jason_screate