Issue2465

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

Created on 2016-02-10.18:45:44 by jason_s, last changed 2016-02-12.17:27:55 by amak.

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.
History
Date User Action Args
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