11import json
22import os
3+ import queue
34import sys
45import time
56import traceback
67import types
78import unittest
8- from queue import Queue
99from test import support
1010try :
1111 import threading
2121# the test is running in background
2222PROGRESS_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
2528def 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
147150def 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