[IronPython] Foolproof IP Embedding

Alex alex at glumol.com
Thu Jul 8 23:34:28 CEST 2010


Hello
In my WPF application, I want to have an "expert mode" that lets the
end-user write inline python code targetting one specific control (a
sheetmusic). I embed IronPython and when the user code throws an exception I
catch it and display it but there are a few foolproof problems:

1) If the user write some bad code in a function and binds it to one of the
control event, it will crash the whole app. Of course I can recommand my
users to always wrap event handlers into a try catch block (or ask to use a
decorator that do it) but it's not really foolproof. I want to make it
impossible to crash the whole app with user code. Perhaps native events
mecanism is a bit too low-level to be foolproof?

2) If the user code makes  an infinite loop it will hang the whole app. I
want to have a "panic button" to stop the script (and even restart the
python engine if necessary). I suppose I have to run user code in a worker
thread but then the user have to use Invoke mecanisms each time he touchs an
UI object? Is there an elegant pattern that deals with this concerns?

This questions are more about .NET and patterns than IronPython, but I
figured some of you have already thought about it in your IP experience.
Thanks for any advices!

Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100708/4d510db9/attachment.html>


More information about the Ironpython-users mailing list