[Ironpython-users] IronPython (ScriptEngine) is not thread safe?

Zsidó Zoltán zsidoz at innodev.hu
Mon Mar 2 13:24:51 CET 2015


Hi,


This is about: https://github.com/IronLanguages/main/issues/1173

I have never analysed IronPython source code, I just try to help you.

I modified:

IronPython-2.7.5\main-ipy-2.7-maint\Languages\IronPython\IronPython\Runtime\WeakRef.cs

to this:

        public void ChainCallback(object callback, object weakRef) {

            lock (callbacks)

            {

                callbacks.Add(new CallbackInfo(callback, weakRef));

            }

        }



Now it is better.



Now sometimes I get this exceptions:

'module' object has no attribute '__all__'

   at Microsoft.Scripting.Runtime.LightExceptions.CheckAndThrow(Object 
value)

   at os$10._get_exports_list$98(PythonFunction $function, Object module) 
hely: C:\Program Files (x86)\IronPython 2.7\Lib\os.py, sor: 39

   at IronPython.Runtime.FunctionCaller`1.Call1(CallSite site, CodeContext 
context, Object func, T0 arg0)

   at 
System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite 
site, T0 arg0, T1 arg1, T2 arg2)

   at os$10.os(FunctionCode $functionCode) hely: C:\Program Files 
(x86)\IronPython 2.7\Lib\os.py, sor: 743

   at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)

   at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope)

   at IronPython.Runtime.PythonContext.InitializeModule(String fileName, 
ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options)

   at IronPython.Runtime.PythonContext.CompileModule(String fileName, String 
moduleName, SourceUnit sourceCode, ModuleOptions options, ScriptCode& 
scriptCode)

   at IronPython.Runtime.PythonContext.CompileModule(String fileName, String 
moduleName, SourceUnit sourceCode, ModuleOptions options)

…

I do not know why but I cannot localize the error because

putting breakpoint to LightExceptions.CheckAndThrow(Object value) method was 
not working

and this error  rarely occurs

Best Regards

David

----- Eredeti üzenet ----- 
From: Jeff Hardy
Sent: Sunday, March 1, 2015 4:42 PM
To: Jeffrey Zhao
Cc: ironpython-users at python.org
Subject: Re: [Ironpython-users] IronPython (ScriptEngine) is not thread 
safe?

On Thu, Feb 26, 2015 at 9:39 AM, Jeffrey Zhao <jeffz at live.com> wrote:
>  Hi guys,
>
> I've met an issue when trying to use multiple ScriptEngine instances in
> parallel, since there's no information saying that a single ScriptEngine
> instance could be used concurrently. Please note "thread-safe" is not 
> enough
> for me. What I need is the real parallelized execution in multiple 
> threads,
> so I'm trying to use separated ScriptEngine instances in different 
> threads.

In theory ScriptEngines should be independent and able to run in
parallel without issues. However, there might be interactions with
other parts that still have threading issues (this, BTW, is why
CPython uses a GIL - writing a free-threaded runtime correctly is
*hard*, and it's far to easy to bugs to slip in inadvertantly.)

It looks like this is that same as
https://github.com/IronLanguages/main/issues/1173 that was opened
recently with basically the same problem - there might be a race
condition in the weakref module. I'll try and track it down since
there's a couple of good small test cases to work from.

- Jeff
_______________________________________________
Ironpython-users mailing list
Ironpython-users at python.org
https://mail.python.org/mailman/listinfo/ironpython-users 



More information about the Ironpython-users mailing list