Skip to content

Commit 1bf6c47

Browse files
committed
regrtest: when parallel tests are interrupted, display progress
1 parent 896dbc7 commit 1bf6c47

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

Lib/test/libregrtest/runtest_mp.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
# Display the running tests if nothing happened last N seconds
2222
PROGRESS_UPDATE = 30.0 # seconds
2323

24+
# If interrupted, display the wait process every N seconds
25+
WAIT_PROGRESS = 2.0 # seconds
26+
2427

2528
def run_test_in_subprocess(testname, ns):
2629
"""Run the given test in a subprocess with --slaveargs.
@@ -224,9 +227,18 @@ def get_running(workers):
224227
if use_timeout:
225228
faulthandler.cancel_dump_traceback_later()
226229

227-
running = [worker.current_test for worker in workers]
228-
running = list(filter(bool, running))
229-
if running:
230-
print("Waiting for %s" % ', '.join(running))
231-
for worker in workers:
232-
worker.join()
230+
# If tests are interrupted, wait until tests complete
231+
wait_start = time.monotonic()
232+
while True:
233+
running = [worker.current_test for worker in workers]
234+
running = list(filter(bool, running))
235+
if not running:
236+
break
237+
238+
dt = time.monotonic() - wait_start
239+
line = "Waiting for %s (%s tests)" % (', '.join(running), len(running))
240+
if dt >= WAIT_PROGRESS:
241+
line = "%s since %.0f sec" % (line, dt)
242+
print(line)
243+
for worker in workers:
244+
worker.join(WAIT_PROGRESS)

0 commit comments

Comments
 (0)