Set Sikuli MaxRunTime for a Test

Asked by Chetan on 2021-03-05

Hi
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.

Thanks
Chetan

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
2021-03-05
Last reply:
2021-03-05
RaiMan (raimund-hocke) said : #1

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)

RaiMan (raimund-hocke) said : #2

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

RaiMan (raimund-hocke) said : #3

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.