Slightly reduce run_tests.py CPU usage.
The watch_kill_switch loop was pretty busy, adding a simple timeout reduces CPU consumption. The CPU consumption of run_tests.py is still higher than I'd expect to just update a terminal, but I don't know where to investigate further.
This commit is contained in:
parent
3b679b0ce3
commit
68e22b2d14
|
@ -221,6 +221,7 @@ def run_test(test, status_queue, kill_switch, verbose=False, stuck_timeout=None,
|
|||
# Poll the kill switch.
|
||||
def watch_kill_switch():
|
||||
while True:
|
||||
interval = 1.0
|
||||
if test_status[0] is not RUNNING:
|
||||
break
|
||||
if kill_switch.wait(1):
|
||||
|
@ -228,6 +229,7 @@ def run_test(test, status_queue, kill_switch, verbose=False, stuck_timeout=None,
|
|||
break
|
||||
test_status[0] = CANCELLED
|
||||
kill_family(grace_period, process.pid)
|
||||
time.sleep(interval)
|
||||
kill_switch_thread = threading.Thread(target=watch_kill_switch)
|
||||
kill_switch_thread.daemon = True
|
||||
kill_switch_thread.start()
|
||||
|
|
Loading…
Reference in New Issue