[Python-checkins] cpython: regrtest: when parallel tests are interrupted, display progress

victor.stinner python-checkins at python.org
Thu Mar 24 07:18:22 EDT 2016


https://hg.python.org/cpython/rev/73f477dddcff
changeset:   100713:73f477dddcff
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Thu Mar 24 12:04:15 2016 +0100
summary:
  regrtest: when parallel tests are interrupted, display progress

files:
  Lib/test/libregrtest/runtest_mp.py |  24 +++++++++++++----
  1 files changed, 18 insertions(+), 6 deletions(-)


diff --git a/Lib/test/libregrtest/runtest_mp.py b/Lib/test/libregrtest/runtest_mp.py
--- a/Lib/test/libregrtest/runtest_mp.py
+++ b/Lib/test/libregrtest/runtest_mp.py
@@ -21,6 +21,9 @@
 # Display the running tests if nothing happened last N seconds
 PROGRESS_UPDATE = 30.0   # seconds
 
+# If interrupted, display the wait process every N seconds
+WAIT_PROGRESS = 2.0   # seconds
+
 
 def run_test_in_subprocess(testname, ns):
     """Run the given test in a subprocess with --slaveargs.
@@ -224,9 +227,18 @@
         if use_timeout:
             faulthandler.cancel_dump_traceback_later()
 
-    running = [worker.current_test for worker in workers]
-    running = list(filter(bool, running))
-    if running:
-        print("Waiting for %s" % ', '.join(running))
-    for worker in workers:
-        worker.join()
+    # If tests are interrupted, wait until tests complete
+    wait_start = time.monotonic()
+    while True:
+        running = [worker.current_test for worker in workers]
+        running = list(filter(bool, running))
+        if not running:
+            break
+
+        dt = time.monotonic() - wait_start
+        line = "Waiting for %s (%s tests)" % (', '.join(running), len(running))
+        if dt >= WAIT_PROGRESS:
+            line = "%s since %.0f sec" % (line, dt)
+        print(line)
+        for worker in workers:
+            worker.join(WAIT_PROGRESS)

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list