From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Wed, 6 Mar 2024 22:20:37 +0000 (+0100) Subject: [3.11] gh-88118: Fix some test_multiprocessing flakiness. (GH-116434) (GH-116441) X-Git-Tag: v3.11.9~87 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=22eb97cf9b6505ac44ed693abd4cc684052c39ee;p=thirdparty%2FPython%2Fcpython.git [3.11] gh-88118: Fix some test_multiprocessing flakiness. (GH-116434) (GH-116441) Fix some test_multiprocessing flakiness. Potentially introduced by https://github.com/python/cpython/pull/25845 not joining that thread likely leads to recently observed "environment changed" logically passing but overall failing tests seen on some buildbots similar to: ``` 1 test altered the execution environment (env changed): test.test_multiprocessing_fork.test_processes 2 re-run tests: test.test_multiprocessing_fork.test_processes test.test_multiprocessing_forkserver.test_processes ``` (cherry picked from commit ea1803e608a7aaf9cf2c07e510d8540d46d3b9ad) Co-authored-by: Gregory P. Smith --- diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index 60e7000c48fa..e096401c4cf3 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -3474,15 +3474,20 @@ class _TestListener(BaseTestCase): client = self.connection.Client(addr, authkey=authkey) client.send(1729) - key = b"" + key = b'' with self.connection.Listener(authkey=key) as listener: - threading.Thread(target=run, args=(listener.address, key)).start() - with listener.accept() as d: - self.assertEqual(d.recv(), 1729) + thread = threading.Thread(target=run, args=(listener.address, key)) + thread.start() + try: + with listener.accept() as d: + self.assertEqual(d.recv(), 1729) + finally: + thread.join() if self.TYPE == 'processes': - self.assertRaises(OSError, listener.accept) + with self.assertRaises(OSError): + listener.accept() @unittest.skipUnless(util.abstract_sockets_supported, "test needs abstract socket support")