Skip to content

Commit 0150595

Browse files
[3.12] gh-88118: Fix some test_multiprocessing flakiness. (GH-116434) (GH-116440)
Fix some test_multiprocessing flakiness. Potentially introduced by #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 ea1803e) Co-authored-by: Gregory P. Smith <[email protected]>
1 parent 0a01ed6 commit 0150595

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3475,15 +3475,20 @@ def run(addr, authkey):
34753475
client = self.connection.Client(addr, authkey=authkey)
34763476
client.send(1729)
34773477

3478-
key = b""
3478+
key = b''
34793479

34803480
with self.connection.Listener(authkey=key) as listener:
3481-
threading.Thread(target=run, args=(listener.address, key)).start()
3482-
with listener.accept() as d:
3483-
self.assertEqual(d.recv(), 1729)
3481+
thread = threading.Thread(target=run, args=(listener.address, key))
3482+
thread.start()
3483+
try:
3484+
with listener.accept() as d:
3485+
self.assertEqual(d.recv(), 1729)
3486+
finally:
3487+
thread.join()
34843488

34853489
if self.TYPE == 'processes':
3486-
self.assertRaises(OSError, listener.accept)
3490+
with self.assertRaises(OSError):
3491+
listener.accept()
34873492

34883493
@unittest.skipUnless(util.abstract_sockets_supported,
34893494
"test needs abstract socket support")

0 commit comments

Comments
 (0)