From: Victor Stinner Date: Tue, 3 Jul 2018 11:43:24 +0000 (+0200) Subject: bpo-33735: Fix test_multiprocessing random failure (GH-8059) (GH-8061) X-Git-Tag: v2.7.16rc1~219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53fafafa340e292a1c9e4aacf5860999613c2b36;p=thirdparty%2FPython%2Fcpython.git bpo-33735: Fix test_multiprocessing random failure (GH-8059) (GH-8061) 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 23401fb960bb94e6ea62d2999527968d53d3fc65) --- diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index b6747effc2c5..42ccbcdf675d 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -1260,10 +1260,10 @@ class _TestPool(BaseTestCase): self.assertRaises(SayWhenError, it.next) def test_imap_unordered(self): - it = self.pool.imap_unordered(sqr, range(1000)) - self.assertEqual(sorted(it), map(sqr, range(1000))) + it = self.pool.imap_unordered(sqr, range(100)) + self.assertEqual(sorted(it), map(sqr, range(100))) - it = self.pool.imap_unordered(sqr, range(1000), chunksize=53) + it = self.pool.imap_unordered(sqr, range(1000), chunksize=100) self.assertEqual(sorted(it), map(sqr, range(1000))) def test_imap_unordered_handle_iterable_exception(self):