Alex News wrote:
In the general case this isn't possible:
http://en.wikipedia.org/wiki/Halting_problem
Well it's not strictly a halting problem. The question isn't whether it
will *ever* terminate but just is it taking too long.
IronPython doesn't include this functionality built in but it would be
*possible* (theoretically) to count loops. I don't think it is a very
useful approach though - a very tight loop can execute thousands of
times in a second.
Perhaps some sort of timeout logic would work for you? I.e. kill the
script if it is still running after some predetermined amount of time.
I do not know if IronPython has any such functionality built in, but
it should be easy enough to roll your own.
I agree - spin the code up in its own thread and kill it if it doesn't
end within a preset maximum time.
Michael
On 4/18/09, theoobe <omgomg...@f2s.com> wrote:
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
infinate, 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?
Thanks alot!
--
View this message in context:
http://www.nabble.com/Is-it-possible-to-set-a-maximum-loop-size-for-scripts--tp23084739p23084739.html
Sent from the IronPython mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com