diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-09-30 01:05:43 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-09-30 01:05:43 (GMT) |
commit | 17f97166766fd2ebe46df0f9fe9308182d141529 (patch) | |
tree | 13662acf57d74c7821bfee4614313780e453bef8 /Lib/test/libregrtest/runtest_mp.py | |
parent | b40843546b1dc558da7217f8c0fe72fbca38e797 (diff) | |
download | cpython-17f97166766fd2ebe46df0f9fe9308182d141529.zip cpython-17f97166766fd2ebe46df0f9fe9308182d141529.tar.gz cpython-17f97166766fd2ebe46df0f9fe9308182d141529.tar.bz2 |
Issue #25220, libregrtest: more verbose output for -jN
When the -jN command line option is used, display tests running since at least
30 seconds every minute.
Diffstat (limited to 'Lib/test/libregrtest/runtest_mp.py')
-rw-r--r-- | Lib/test/libregrtest/runtest_mp.py | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/Lib/test/libregrtest/runtest_mp.py b/Lib/test/libregrtest/runtest_mp.py index 6ed8dc2..b31b51e 100644 --- a/Lib/test/libregrtest/runtest_mp.py +++ b/Lib/test/libregrtest/runtest_mp.py @@ -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) |