← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #258380]: Any way to restart Sikuli script execution?

 

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

RaiMan proposed the following answer:
WARNING: Do not use the solution in comment #5, since it has the risk of
running into a stack overflow, since test2 and test3 are calling each
other without terminating before.

Infinte loops always have the challenge of how to stop them gracefully. 
The only easy solution, is to check an external state at the beginning of every loop turn and end the loop, if that signals so.

a trigger example:
loop runs as long as a specific file exists and stops if it does not (because it was deleted outside somehow, which could be manually or by some other watch dog) 

such a solution can live within one script:

# outer loop for start and restart
while someConditionIsTrue():
  # do your setup for the workload loop
  while someOtherConditionIsTrue():
    # here goes you work script

you need the 2 defs 
def someConditionIsTrue():
   #returns True (should continue) or False

def someOtherConditionIsTrue():
   #returns True (should continue) or False

Possible things to check are the time of day, run duration, existence of
a file, something visible on the screen, mousepointer moved somewhere,
...

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