[IronPython] Thread safety with Stdout

Ásgeir Halldórsson asgeir at dcc.is
Sat Jun 28 02:29:11 PDT 2008


Hi,

    I was wondering about one thing I am using this code in many
threads.  And it does not look like the Stdout is thread safe.  Is there
something I can do about it?

ScriptEngine eng = IronPython.Hosting.PythonEngine.CurrentEngine;
ScriptSource source = eng.CreateScriptSourceFromString(codeStr,
Microsoft.Scripting.SourceCodeKind.Statements);
code = source.Compile();

ScriptScope scope = eng.CreateScope();

MemoryStream ms = new MemoryStream();
scope.Engine.Runtime.IO.SetOutput(ms, Encoding.UTF8);
code.Execute(scope);

-- 

Regards,
   Ásgeir Halldórsson





More information about the Users mailing list