Yep, you're correct - SystemState is currently a singleton for the entire 
process.  We'll actually have this fixed in beta 7 where the system state is 
stored in a hidden spot in the module and we'll flow it as one module imports 
another.  That'll result in a set of modules being independent and 'belonging' 
to a single system state and allows multiple engines to be hosted 
simultaneously.

The engine does have a SetStderr / SetStdout / SetStdin API which should be 
used for this purpose.  And the nice thing is as we rev to the multi-System 
state module this API will remain unchanged so you won't be broken in the 
future.


Do you want to help develop Dynamic languages on CLR? 
(http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Thursday, April 27, 2006 4:32 AM
To: [email protected]
Subject: [IronPython] Generated IL is always using the standard input, output 
and error streams.

Hi,

First, thanks Dino and Szymon for the help <Re: Using an IronPython
console with a Winforms component supporting the interactive I/O>

I came across an issue: the only output displayed were stack traces.

After a bit of investigation, I think the generated IL does not use the
custom streams of the implementation of IConsole passed to the
PythonEngine. The static property State of IP::Runtime::Ops is
initialised with a SystemState setting its fields e.g. as:

        [PythonName("__stdout__")]
        public object __stdout__ = new PythonFile(
            Options.UnbufferedStdOutAndError ?
Console.OpenStandardOutput(0) : Console.OpenStandardOutput(),
            Console.OutputEncoding,
            "<stdout>",
            "w");

I think that the subsequent calls to the methods in the Ops class from
the generated methods are using this State.

Incidentally, the use of static methods/properties for Ops also
effectively means that a PythonEngine should be used as a singleton if
embedded in an application. I am well aware that trying not to rely on
static method and singleton patterns often raises the code complexity a
*lot* (been there, done that...). What is the current thinking on this
topic?

Cheers,
J-M

_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to