Set Sikuli MaxRunTime for a Test

Asked by Chetan

i have multople test and i would like to have a max run time or Stop time after which a test should stop and java process ends

this is required as there could be multiple test running indefinetly on machine and after some time test may be consume system memory.


Question information

English Edit question
SikuliX Edit question
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :

currently not a feature of SikuliX.

I will check the next days for a solution.

--- possible ways
- use system features in a command script to kill the java run after some time
- in the script run use a subprocess, that waits and finally kills the main process

I will put this on the list as a feature for the SikuliX script runner (2.0.6)

Revision history for this message
RaiMan (raimund-hocke) said :

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:
        maxTime += 1
        if stop.isSet():
            print "wait stopped %d" % maxTime

    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))

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

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

Revision history for this message
RaiMan (raimund-hocke) said :

Sorry, was for macOS.

on Windows it is:

type("C", Key.ALT) # stops the running script

Can you help with this problem?

Provide an answer of your own, or ask Chetan for more information if necessary.

To post a message you must log in.