]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-130730: Fix multiprocessing test_active_children() (GH-130837) (#130845)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 4 Mar 2025 17:28:33 +0000 (18:28 +0100)
committerGitHub <noreply@github.com>
Tue, 4 Mar 2025 17:28:33 +0000 (17:28 +0000)
gh-130730: Fix multiprocessing test_active_children() (GH-130837)

Replace a sleep with an event: sleep is not a reliable
synchronization primitive.
(cherry picked from commit 3dd3675492a3fc3b7996613ef75a9044ee7449b0)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/_test_multiprocessing.py

index d7de0f7113fe1989aca0c06194e31d53a449a069..4f77b419d4e52a0173c8fe11e79b09fa63d363db 100644 (file)
@@ -588,12 +588,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())