← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #695869]: Set Sikuli MaxRunTime for a Test

 

Question #695869 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/695869

RaiMan proposed the following answer:
this is a quick&dirty solution, that works inside a script:

from threading import Thread
from threading import Event

def toRun(waitTime, stop):
    maxTime = 0
    while maxTime < waitTime: 
        wait(1)
        maxTime += 1
        if stop.isSet():
            print "wait stopped %d" % maxTime
            return
        
    print "after wait: %d" % maxTime
    type("C", Key.CMD) # stops the running script

stop = Event()
# 10 means stop before hover()
# 20 means normal termination
t1 = Thread(target = toRun, args = (10, stop))
t1.start()

# some things to be done (your script code here)
wait(15)
print "before hover"
hover()

stop.set() # needed to end the toRun thread

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.