cmd1 = f"{BIN_ARNIED_HELPER} --is-scheduled-or-running GENERATE"
cmd2 = f"{BIN_ARNIED_HELPER} --is-scheduled-or-running GENERATE_OFFLINE"
end_time = time.monotonic() + timeout - 0.5
- while run_cmd(cmd=cmd1, ignore_errors=True, vm=vm).returncode == 0 \
- or run_cmd(cmd=cmd2, ignore_errors=True, vm=vm).returncode == 0:
- # one of them is scheduled or running, so check timeout and wait
- if time.monotonic() > end_time:
- log.warning("Timeout waiting for generate to start/finish")
- return False
+
+ while time.monotonic() < end_time:
+ # from docu of arnied_helper:
+ # --is-scheduled-or-running PROGNAME Exit code 0 if scheduled or running, 1 otherwise
+ if run_cmd(cmd=cmd1, ignore_errors=True, vm=vm).returncode == 1 \
+ and run_cmd(cmd=cmd2, ignore_errors=True, vm=vm).returncode == 1:
+ # both commands succeeded and indicate that neither program is running nor scheduled
+ return True
log.debug("Waiting for generate to start/finish...")
time.sleep(1)
- return True
\ No newline at end of file
+ log.warning("Timeout waiting for generate to start/finish")
+ return False