Skip to content

Commit 3bd9d3b

Browse files
bpo-33735: Fix test_multiprocessing random failure (GH-8059)
When hunting memory leaks using -R 3:3, test_imap_unordered() of test_multiprocessing leaks randomly a few memory blocks. It is a false alarm: when testing using -R 3:20 for example, no leak is detected. Modify test_imap_unordered() to be closer to test_imap(): * Only test 10 numbers instead of 1000: it's a pool of 4 processes, so 10 is enough to test at least one number per process * Use chunksize=100 instead of chunksize=53 to mimick test_imap() (cherry picked from commit 23401fb) Co-authored-by: Victor Stinner <[email protected]>
1 parent 580c7db commit 3bd9d3b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,10 +2085,10 @@ def test_imap_handle_iterable_exception(self):
20852085
self.assertRaises(SayWhenError, it.__next__)
20862086

20872087
def test_imap_unordered(self):
2088-
it = self.pool.imap_unordered(sqr, list(range(1000)))
2089-
self.assertEqual(sorted(it), list(map(sqr, list(range(1000)))))
2088+
it = self.pool.imap_unordered(sqr, list(range(10)))
2089+
self.assertEqual(sorted(it), list(map(sqr, list(range(10)))))
20902090

2091-
it = self.pool.imap_unordered(sqr, list(range(1000)), chunksize=53)
2091+
it = self.pool.imap_unordered(sqr, list(range(1000)), chunksize=100)
20922092
self.assertEqual(sorted(it), list(map(sqr, list(range(1000)))))
20932093

20942094
def test_imap_unordered_handle_iterable_exception(self):

0 commit comments

Comments
 (0)