aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/_test_multiprocessing.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2025-03-04 18:05:20 +0100
committerGitHub <noreply@github.com>2025-03-04 17:05:20 +0000
commit3dd3675492a3fc3b7996613ef75a9044ee7449b0 (patch)
treec2688a8049650d23cacce23c001075397fd34657 /Lib/test/_test_multiprocessing.py
parent885c3d126f39711971d84a2dee04c19df8a301e4 (diff)
downloadcpython-3dd3675492a3fc3b7996613ef75a9044ee7449b0.tar.gz
cpython-3dd3675492a3fc3b7996613ef75a9044ee7449b0.zip
gh-130730: Fix multiprocessing test_active_children() (#130837)
Replace a sleep with an event: sleep is not a reliable synchronization primitive.
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r--Lib/test/_test_multiprocessing.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index f31151e53c4..67ab8f098f7 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -589,12 +589,16 @@ class _TestProcess(BaseTestCase):
def test_active_children(self):
self.assertEqual(type(self.active_children()), list)
- p = self.Process(target=time.sleep, args=(DELTA,))
+ event = self.Event()
+ p = self.Process(target=event.wait, args=())
self.assertNotIn(p, self.active_children())
- p.daemon = True
- p.start()
- self.assertIn(p, self.active_children())
+ try:
+ p.daemon = True
+ p.start()
+ self.assertIn(p, self.active_children())
+ finally:
+ event.set()
p.join()
self.assertNotIn(p, self.active_children())