]> granicus.if.org Git - python/commitdiff
Issue #25220, libregrtest: more verbose output for -jN
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 30 Sep 2015 01:05:43 +0000 (03:05 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 30 Sep 2015 01:05:43 +0000 (03:05 +0200)
When the -jN command line option is used, display tests running since at least
30 seconds every minute.

Lib/test/libregrtest/runtest_mp.py

index 6ed8dc2538a0bae53e84c8bfe3c9a35a586b2eee..b31b51e142446cb505cc65595f8ac5aae5593443 100644 (file)
@@ -1,11 +1,11 @@
 import json
 import os
+import queue
 import sys
 import time
 import traceback
 import types
 import unittest
-from queue import Queue
 from test import support
 try:
     import threading
@@ -21,6 +21,9 @@ from test.libregrtest.setup import setup_tests
 # the test is running in background
 PROGRESS_MIN_TIME = 30.0   # seconds
 
+# Display the running tests if nothing happened last N seconds
+PROGRESS_UPDATE = 60.0   # seconds
+
 
 def run_test_in_subprocess(testname, ns):
     """Run the given test in a subprocess with --slaveargs.
@@ -145,18 +148,39 @@ class MultiprocessThread(threading.Thread):
 
 
 def run_tests_multiprocess(regrtest):
-    output = Queue()
+    output = queue.Queue()
     pending = MultiprocessIterator(regrtest.tests)
 
     workers = [MultiprocessThread(pending, output, regrtest.ns)
                for i in range(regrtest.ns.use_mp)]
     for worker in workers:
         worker.start()
+
+    def get_running(workers):
+        running = []
+        for worker in workers:
+            current_test = worker.current_test
+            if not current_test:
+                continue
+            dt = time.monotonic() - worker.start_time
+            if dt >= PROGRESS_MIN_TIME:
+                running.append('%s (%.0f sec)' % (current_test, dt))
+        return running
+
     finished = 0
     test_index = 1
+    timeout = max(PROGRESS_UPDATE, PROGRESS_MIN_TIME)
     try:
         while finished < regrtest.ns.use_mp:
-            test, stdout, stderr, result = output.get()
+            try:
+                item = output.get(timeout=PROGRESS_UPDATE)
+            except queue.Empty:
+                running = get_running(workers)
+                if running:
+                    print('running: %s' % ', '.join(running))
+                continue
+
+            test, stdout, stderr, result = item
             if test is None:
                 finished += 1
                 continue
@@ -168,14 +192,7 @@ def run_tests_multiprocess(regrtest):
             if (ok not in (CHILD_ERROR, INTERRUPTED)
                 and test_time >= PROGRESS_MIN_TIME):
                 text += ' (%.0f sec)' % test_time
-            running = []
-            for worker in workers:
-                current_test = worker.current_test
-                if not current_test:
-                    continue
-                dt = time.monotonic() - worker.start_time
-                if dt >= PROGRESS_MIN_TIME:
-                    running.append('%s (%.0f sec)' % (current_test, dt))
+            running = get_running(workers)
             if running:
                 text += ' -- running: %s' % ', '.join(running)
             regrtest.display_progress(test_index, text)