Hi,
I am using Ironpython to connect to a legacy python code from C#.
I am not fully familiar with Ironpython, but managed to get it working for a 
single-threaded application. 
This is how I implemented this:

                ScriptEngine engine = Python.CreateEngine();
                ScriptRuntime runtime = engine.Runtime;
                ScriptScope scope = runtime.CreateScope();
                ops = engine.Operations;
                ScriptSource source = 
engine.CreateScriptSourceFromFile("ironpython.py");
                source.Execute(scope);
                string class_param = rule;
                object[] parameters = new object[1];
                parameters[0] = class_param;
                object klass = scope.GetVariable("model_checker");
                object instance = ops.Invoke(klass, parameters);
                method = ops.GetMember(instance, "check_model");

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.
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.

Is there anything specific that I should do to generate multiple scripting 
engines running in separate threads without interfering with each other?

any ideas greatly appreciated
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to