When I do something like
while True:
print(\'loop\')
and execute that code in sublime I am not able to stop it. I have to manually kill
You have a couple of options here. You could set a huge maximum number of iterations (I actually do this with most while loops until I've completely debugged my code, to avoid infinite loop pains): So for example
max_iterations = 100000000
while i < max_iterations:
print("Hello World")
An alternative would be using time module to clock the execution time of your code like this
import time
max_execution_time = 10000000 #this will be in seconds
start_time = time.clock()
elapsed_time = 0
while elapsed_time < max_execution_time:
elapsed_time = time.clock() = start_time
#Your loop code here