diff options
author | Gregory P. Smith <greg@krypto.org> | 2024-03-06 21:39:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-06 21:39:06 (GMT) |
commit | ea1803e608a7aaf9cf2c07e510d8540d46d3b9ad (patch) | |
tree | f90c445473add119c9f471bfeb1139eaa21dd593 /Lib/test/_test_multiprocessing.py | |
parent | c62144a02cfae412a9deb4059fae141693a6edc9 (diff) | |
download | cpython-ea1803e608a7aaf9cf2c07e510d8540d46d3b9ad.zip cpython-ea1803e608a7aaf9cf2c07e510d8540d46d3b9ad.tar.gz cpython-ea1803e608a7aaf9cf2c07e510d8540d46d3b9ad.tar.bz2 |
gh-88118: Fix some test_multiprocessing flakiness. (#116434)
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
```
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r-- | Lib/test/_test_multiprocessing.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index 058537b..b63b567 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -3513,15 +3513,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") |