[IronPython] Is it possible to set a maximum loop size for scripts?
Jimmy Schementi
Jimmy.Schementi at microsoft.com
Tue Apr 21 22:24:27 CEST 2009
> I have a C# application with IronPython scripting. I wonder, is it
> possible to prevent users from creating infinite loops in their
> scripts?
>
> So for example, if a script is executed which contains a loop, and loop
> is infinite, would it be possible for my C# application to detect this,
> perhaps by having a maximum loop cycle count? Thus preventing my
> application from hanging...
>
> I've tried googling around on this subject but I've had no joy. Maybe
> what I'm asking for isn't possible?
There is no general solution: http://en.wikipedia.org/wiki/Halting_problem
But you can stop your app from hanging by running scripts on another thread. You can also stop the thread after a certain amount of time, thus accomplishing a similar thing as a cycle count. However, again, there is no general solution.
More information about the Ironpython-users
mailing list