From: <joh...@no...> - 2010-03-10 14:40:01
|
I think it's too easy for anyone new to the framework to believe an instance of PythonInterpreter is a new fresh not-connected to anything previous instance. It would make more sense to make PythonInterpreter totally independent, and create another class that makes use of this 'shared' state, and have that very well documented (what's shared, threadsafeness, etc.) From: Santosh Tiwari [mailto:ti...@gm...] Sent: 10 March 2010 14:27 To: Baker, John (IT/UK); jyt...@li... Subject: Re: [Jython-users] Redirecting stdout from PythonInterpreter So, it is generally a good idea to always create a new PySystemState and pass it to the constructor when creating a new instance of PythonInterpreter if we want the two instances to be completely independent. On Wed, Mar 10, 2010 at 6:05 AM, <joh...@no...> wrote: Right. I had previously created a PythonInterpreter and need to create a new one with a separate state for each stdout stream: PythonInterpreter.initialize(System.getProperties(), null, new String[0]); PySystemState systemState = new PySystemState(); pi = new PythonInterpreter(null, systemState); pi.setOut(outputStream); pi.setErr(outputStream); I think PythonInterpreter could be improved by making that more obvious, or by creating two versions of it - one which uses a 'shared state' and another which creates a new PySystemState each time it's constructed. This e-mail (including any attachments) is confidential, may contain proprietary or privileged information and is intended for the named recipient(s) only. Unintended recipients are prohibited from taking action on the basis of information in this e-mail and must delete all copies. Nomura will not accept responsibility or liability for the accuracy or completeness of, or the presence of any virus or disabling code in, this e-mail. If verification is sought please request a hard copy. Any reference to the terms of executed transactions should be treated as preliminary only and subject to formal written confirmation by Nomura. Nomura reserves the right to monitor e-mail communications through its networks (in accordance with applicable laws). No confidentiality or privilege is waived or lost by Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is a reference to any entity in the Nomura Holdings, Inc. group. Please read our Electronic Communications Legal Notice which forms part of this e-mail: http://www.Nomura.com/email_disclaimer.htm |