Skip to content

Commit

Permalink
pythongh-88118: Fix some test_multiprocessing flakiness. (pythonGH-11…
Browse files Browse the repository at this point in the history
…6434)

Fix some test_multiprocessing flakiness.

Potentially introduced by python#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 <greg@krypto.org>
  • Loading branch information
gpshead authored and miss-islington committed Mar 6, 2024
1 parent e8fb762 commit 87eaa34
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3474,15 +3474,20 @@ def run(addr, authkey):
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")
Expand Down

0 comments on commit 87eaa34

Please sign in to comment.