From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 4 Mar 2025 17:28:33 +0000 (+0100) Subject: [3.13] gh-130730: Fix multiprocessing test_active_children() (GH-130837) (#130845) X-Git-Tag: v3.13.3~169 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=22d729cf5db6b03930d52c648327e0d953f9e3bc;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-130730: Fix multiprocessing test_active_children() (GH-130837) (#130845) 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 --- diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index d7de0f7113fe..4f77b419d4e5 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -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())