[IronPython] Thread safety with Stdout

Curt Hagenlocher curt at hagenlocher.org
Sat Jun 28 14:46:13 CEST 2008


This is a known problem and already filed in CodePlex as
http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16623.  You
might be able to guard the stream yourself using locks created through the
thread or threading modules.  Relevant documentation can be found at
http://docs.python.org/lib/module-thread.html and
http://docs.python.org/lib/module-threading.html.

Only two votes so far, but I think we'd probably want to fix this for 2.0
final.
On Sat, Jun 28, 2008 at 2:29 AM, Ásgeir Halldórsson <asgeir at dcc.is> wrote:

> 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
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080628/effb0e19/attachment.html>


More information about the Ironpython-users mailing list