mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-02 10:23:25 +08:00
autotest: remove unnecessary busy loop from example runner
It never exited early in the normal case and just burned 100% CPU. It will be slightly slower in an error case if there is an unexpected early exit but that is probably worth the simplification.
This commit is contained in:
committed by
Peter Barker
parent
cec0df68ce
commit
6e816400f3
@@ -36,20 +36,17 @@ def run_example(name, filepath, valgrind=False, gdb=False):
|
||||
]:
|
||||
expect_exit = True
|
||||
|
||||
tstart = time.time()
|
||||
while True:
|
||||
if time.time() - tstart > timeout:
|
||||
break
|
||||
if not expect_exit:
|
||||
retcode = bob.poll()
|
||||
if retcode is not None:
|
||||
raise ValueError("Process exited before I could kill it (%s)" % str(retcode))
|
||||
time.sleep(timeout)
|
||||
|
||||
if expect_exit:
|
||||
retcode = bob.wait()
|
||||
if retcode is None:
|
||||
raise ValueError("Expected example to exit, it did not")
|
||||
else:
|
||||
retcode = bob.poll()
|
||||
if retcode is not None:
|
||||
raise ValueError("Process exited before I could kill it (%s)" % str(retcode))
|
||||
|
||||
bob.send_signal(signal.SIGTERM)
|
||||
time.sleep(1)
|
||||
retcode = bob.poll()
|
||||
|
||||
Reference in New Issue
Block a user