Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 17f9716

Browse files
committed
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.
1 parent b408435 commit 17f9716

1 file changed

Lines changed: 28 additions & 11 deletions

File tree

Lib/test/libregrtest/runtest_mp.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import json
22
import os
3+
import queue
34
import sys
45
import time
56
import traceback
67
import types
78
import unittest
8-
from queue import Queue
99
from test import support
1010
try:
1111
import threading
@@ -21,6 +21,9 @@
2121
# the test is running in background
2222
PROGRESS_MIN_TIME = 30.0 # seconds
2323

24+
# Display the running tests if nothing happened last N seconds
25+
PROGRESS_UPDATE = 60.0 # seconds
26+
2427

2528
def run_test_in_subprocess(testname, ns):
2629
"""Run the given test in a subprocess with --slaveargs.
@@ -145,18 +148,39 @@ def run(self):
145148

146149

147150
def run_tests_multiprocess(regrtest):
148-
output = Queue()
151+
output = queue.Queue()
149152
pending = MultiprocessIterator(regrtest.tests)
150153

151154
workers = [MultiprocessThread(pending, output, regrtest.ns)
152155
for i in range(regrtest.ns.use_mp)]
153156
for worker in workers:
154157
worker.start()
158+
159+
def get_running(workers):
160+
running = []
161+
for worker in workers:
162+
current_test = worker.current_test
163+
if not current_test:
164+
continue
165+
dt = time.monotonic() - worker.start_time
166+
if dt >= PROGRESS_MIN_TIME:
167+
running.append('%s (%.0f sec)' % (current_test, dt))
168+
return running
169+
155170
finished = 0
156171
test_index = 1
172+
timeout = max(PROGRESS_UPDATE, PROGRESS_MIN_TIME)
157173
try:
158174
while finished < regrtest.ns.use_mp:
159-
test, stdout, stderr, result = output.get()
175+
try:
176+
item = output.get(timeout=PROGRESS_UPDATE)
177+
except queue.Empty:
178+
running = get_running(workers)
179+
if running:
180+
print('running: %s' % ', '.join(running))
181+
continue
182+
183+
test, stdout, stderr, result = item
160184
if test is None:
161185
finished += 1
162186
continue
@@ -168,14 +192,7 @@ def run_tests_multiprocess(regrtest):
168192
if (ok not in (CHILD_ERROR, INTERRUPTED)
169193
and test_time >= PROGRESS_MIN_TIME):
170194
text += ' (%.0f sec)' % test_time
171-
running = []
172-
for worker in workers:
173-
current_test = worker.current_test
174-
if not current_test:
175-
continue
176-
dt = time.monotonic() - worker.start_time
177-
if dt >= PROGRESS_MIN_TIME:
178-
running.append('%s (%.0f sec)' % (current_test, dt))
195+
running = get_running(workers)
179196
if running:
180197
text += ' -- running: %s' % ', '.join(running)
181198
regrtest.display_progress(test_index, text)

0 commit comments

Comments
 (0)