<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.E-MailFormatvorlage17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>You can re-read the thread at http://lists.ironpython.com/pipermail/users-ironpython.com/.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>The fastest possibility is:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>- Fetch the IronPython source.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>- Patch PythonContext.GetEqualSite yourself according to the description in the thread.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>- Use your own compiled version.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Gre,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Markus<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>Von:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com] <b>Im Auftrag von </b>surangika ranathunga<br><b>Gesendet:</b> Dienstag, 19. April 2011 04:28<br><b>An:</b> Discussion of IronPython; Jeff Hardy<br><b>Betreff:</b> Re: [IronPython] how to generate multiple concurrent scriptignengines?<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0><tr><td valign=top style='padding:0cm 0cm 0cm 0cm'><div><p class=MsoNormal>Hi,<o:p></o:p></p></div><div><p class=MsoNormal>Sorry I missed the posts on this thread. This is the code that caused me the problem (I posted this in the first post of the thread)<o:p></o:p></p></div><div><p class=MsoNormal>So according to your mails, I take that this is due to a bug in the ironpython code. Is there a way I can have some alternative work-out, something that I can do&nbsp;through my code? (i'm in kind of a hury to finish the project :S )<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;color:#2B91AF'>ScriptEngine</span><span style='font-size:10.0pt;font-family:Consolas'> engine = <span style='color:#2B91AF'>Python</span>.CreateEngine();<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;color:#2B91AF'>ScriptRuntime</span><span style='font-size:10.0pt;font-family:Consolas'> runtime = engine.Runtime;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;color:#2B91AF'>ScriptScope</span><span style='font-size:10.0pt;font-family:Consolas'> scope = runtime.CreateScope();<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>ops = engine.Operations;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;color:blue'>try<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>{<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;color:#2B91AF'>ScriptSource</span><span style='font-size:10.0pt;font-family:Consolas'> source = engine.CreateScriptSourceFromFile(<span style='color:#A31515'>&quot;ironpython.py&quot;</span>);<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>source.Execute(scope);<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;color:blue'>string</span><span style='font-size:10.0pt;font-family:Consolas'> class_param = rule;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;color:blue'>object</span><span style='font-size:10.0pt;font-family:Consolas'>[] parameters = <span style='color:blue'>new</span> <span style='color:blue'>object</span>[1];<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>parameters[0] = class_param;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;color:blue'>object</span><span style='font-size:10.0pt;font-family:Consolas'> klass = scope.GetVariable(<span style='color:#A31515'>&quot;model_checker&quot;</span>);<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;color:blue'>object</span><span style='font-size:10.0pt;font-family:Consolas'> instance = ops.Invoke(klass, parameters);<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>method = ops.GetMember(instance, <span style='color:#A31515'>&quot;check_model&quot;</span>);<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>}<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;color:blue'>catch</span><span style='font-size:10.0pt;font-family:Consolas'> (<span style='color:#2B91AF'>Exception</span> e)<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>{<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas;color:#2B91AF'>Console</span><span style='font-size:10.0pt;font-family:Consolas'>.WriteLine(e.ToString());<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>}<o:p></o:p></span></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal><br><br><span lang=EN-US>--- On <b>Thu, 14/4/11, Jeff Hardy <i>&lt;</i></b></span><b><i><a href="mailto:jdhardy@gmail.com"><span lang=EN-US>jdhardy@gmail.com</span></a></i></b><b><i><span lang=EN-US>&gt;</span></i></b><span lang=EN-US> wrote:<o:p></o:p></span></p></div><blockquote style='border:none;border-left:solid #1010FF 1.5pt;padding:0cm 0cm 0cm 4.0pt;margin-left:3.75pt;margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal style='margin-bottom:12.0pt'><span lang=EN-US><br>From: Jeff Hardy &lt;</span><a href="mailto:jdhardy@gmail.com"><span lang=EN-US>jdhardy@gmail.com</span></a><span lang=EN-US>&gt;<br>Subject: Re: [IronPython] how to generate multiple concurrent scriptign engines?<br>To: &quot;Discussion of IronPython&quot; &lt;</span><a href="mailto:users@lists.ironpython.com"><span lang=EN-US>users@lists.ironpython.com</span></a><span lang=EN-US>&gt;<br>Cc: &quot;surangika ranathunga&quot; &lt;</span><a href="mailto:lady_radsu@yahoo.com"><span lang=EN-US>lady_radsu@yahoo.com</span></a><span lang=EN-US>&gt;<br>Received: Thursday, 14 April, 2011, 7:35 AM<o:p></o:p></span></p><div><p class=MsoNormal>As long as you have a ScriptScope per thread, you should be able to<br>share the ScriptEngine &amp; Runtime between threads.<br><br>What is the exception that you are getting? If it's a GUI program,<br>remember that UI elements can only be manipulated from the main<br>thread.<br><br>- Jeff<br><br>On Thu, Apr 14, 2011 at 1:02 AM, surangika ranathunga<br>&lt;<a href="http://nz.mc1102.mail.yahoo.com/mc/compose?to=lady_radsu@yahoo.com">lady_radsu@yahoo.com</a>&gt; wrote:<br>&gt;<br>&gt; Hi,<br>&gt; I am using Ironpython to connect to a legacy python code from C#.<br>&gt; I am not fully familiar with Ironpython, but managed to get it working for a single-threaded application.<br>&gt; This is how I implemented this:<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ScriptEngine engine = Python.CreateEngine();<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ScriptRuntime runtime = engine.Runtime;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ScriptScope scope = runtime.CreateScope();<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ops = engine.Operations;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ScriptSource source = engine.CreateScriptSourceFromFile(&quot;ironpython.py&quot;);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; source.Execute(scope);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string class_param = rule;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object[] parameters = new object[1];<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parameters[0] = class_param;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object klass = scope.GetVariable(&quot;model_checker&quot;);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object instance = ops.Invoke(klass, parameters);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; method = ops.GetMember(instance, &quot;check_model&quot;);<br>&gt;<br>&gt; Now I want to make my application multi-threaded, and I want to have concurrently running scripting engines. Essentially, these engines should access the same underlying python code, and hence these scripting engines are identical to each other.<br>&gt; Without any change, the above code works fine for most of the time for a multi-threaded application. However, there is an exception that appears from time to time, and I suspect that it is due to a concurrency issue.<br>&gt;<br>&gt; Is there anything specific that I should do to generate multiple scripting engines running in separate threads without interfering with each other?<br>&gt;<br>&gt; any ideas greatly appreciated<br>&gt;<br>&gt; _______________________________________________<br>&gt; Users mailing list<br>&gt; <a href="http://nz.mc1102.mail.yahoo.com/mc/compose?to=Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>&gt; <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>&gt;<o:p></o:p></p></div></blockquote></td></tr></table><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Calibri","sans-serif"'><o:p>&nbsp;</o:p></span></p></div></div></body></html>