Skip to content

Commit 075fcb1

Browse files
authored
Minor parallel_testsuite.py cleanups. NFC (#25161)
- Add some comments - Use `startmap` over `apply_async`. This is basically the same but with one fewer line and avoiding the creation of all the async return values. - Error out of `--failfast` is passed but we cannot support it due to buggy python.
1 parent 7196878 commit 075fcb1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

test/parallel_testsuite.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,21 @@ def run(self, result):
9999
with multiprocessing.Manager() as manager:
100100
with multiprocessing.Pool(use_cores) as pool:
101101
if python_multiprocessing_structures_are_buggy():
102+
# When multuprocessing shared structures are buggy we don't support failfast
103+
# or the progress bar.
102104
failfast_event = progress_counter = lock = None
105+
if self.failfast:
106+
print('The version of python being used is not compatible with --failfast')
107+
sys.exit(1)
103108
else:
104109
failfast_event = manager.Event() if self.failfast else None
105110
progress_counter = manager.Value('i', 0)
106111
lock = manager.Lock()
107-
results = [pool.apply_async(run_test, (t, failfast_event, lock, progress_counter, len(tests))) for t in tests]
108-
results = [r.get() for r in results]
109-
results = [r for r in results if r is not None]
112+
results = pool.starmap(run_test, ((t, failfast_event, lock, progress_counter, len(tests)) for t in tests), chunksize=1)
113+
114+
# Filter out the None results which can occur in failfast mode.
115+
if self.failfast:
116+
results = [r for r in results if r is not None]
110117

111118
if self.failing_and_slow_first:
112119
previous_test_run_results = common.load_previous_test_run_results()

0 commit comments

Comments
 (0)