Increase the run time with sys.setExecutionLimit(msecs)


#1

Hello guys… I’m working in some exercise with turtles (python).
Some draws take more time that I wanted, but there are not any infinite loop.
When I run the code, at some point it shows me this error.
I want to know where I can set the Execution Limit.

Please, I appreciate your help

Error

TimeLimitError: Program exceeded run time limit. on line 100

Description

Your program is running too long. Most programs in this book should run in less than 10 seconds easily. This probably indicates your program is in an infinite loop.

To Fix

Add some print statements to figure out if your program is in an infinte loop. If it is not you can increase the run time with sys.setExecutionLimit(msecs)


#2

There is an example in the Exercises in Chapter 5 (Functions) of the Think Python book. You have to import sys module to use that command:

import sys
sys.setExecutionLimit(35000)    # this gives your code 35 secs to run

A simpler option, which may work, is to set your turtle’s speed to 0. It turns off animation and makes the turtle go as fast as possible:

your_turtle.speed(0)


#3

Thank you very very much Leonid!!! I appreciate it very much!