Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

How to run a GHPython infinite while loop with Timer

$
0
0

Dear all,

The below function is not exiting automatically after 3 seconds. I am unable to figure out the error.

import rhinoscriptsyntax as rs
import time

def runFunction(Run):
    count = 0
    while Run:
        print count
        count += 1
    a = 10
    return a 


Run = True
population = 1
if population == 0:
    population = 1
else:
    population = 1
    
timeout_seconds = 3* population
start_time = time.time()
try:
    while time.time() - start_time <= timeout_seconds:
        a = runFunction(Run)
except:
    print("Timeout! The operation took more than {} seconds.".format(timeout_seconds))
    a = 15

Thanks in advance
vijesh

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles