[IronPython] IronPython and Threads

Dan Eloff dan.eloff at gmail.com
Sun Jun 8 17:23:46 CEST 2008

I'm having a problem debugging some issues that I suspect are thread
related in Silverlight. My application is failing silently, so I have
no way to be sure yet. Is it possible that exceptions in a background
thread are quietly swallowed? I'm pretty sure my callback is being
called, but all that is in it right now is a raise statement.

I've enabled debug.
<param name="initParams" value="debug=true,reportErrors=errorLocation" />

I've been trying to explore Threads a little more with IronPython to
see what might be the problem, but even there I'm not having much
luck. I could swear this used to work in Beta 1. Now it crashes the

IronPython 2.0 Beta ( on .NET 2.0.50727.1433
Copyright (c) Microsoft Corporation. All rights reserved.
>>> from System.Threading import Thread, ThreadStart
>>> def foo():
...     raise ValueError
>>> t = Thread(ThreadStart(foo))
>>> t.Start()
Unhandled Exception: System.ArgumentException
   at foo$1##16(Closure )
   at _stub_##25(Closure , CallSite , CodeContext , Object )
   at Microsoft.Scripting.Utils.InvokeHelper`5.Invoke(Object arg0,
Object arg1, Object arg2, Object arg3)
   at Microsoft.Scripting.Utils.ReflectedCaller.InvokeInstance(Object
instance, Object[] args)
   at Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext
context, CallSite`1 site, Object[] args)
   at Microsoft.Scripting.Actions.UpdateDelegates.Update1[T0,TRet](CallSite
site, CodeContext context, T0 arg0)
   at System.Void(), using PythonBinder##20(Closure )
   at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

What's going wrong? How should I be doing this?


More information about the Ironpython-users mailing list