https://github.com/python/cpython/commit/45e667c7c2d4fda27dbf59be74160a1d5c93c79d commit: 45e667c7c2d4fda27dbf59be74160a1d5c93c79d branch: 3.12 author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com> committer: vstinner <vstin...@python.org> date: 2025-03-04T17:22:12Z summary:
[3.12] gh-130730: Fix multiprocessing test_active_children() (GH-130837) (#130846) 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 <vstin...@python.org> files: M Lib/test/_test_multiprocessing.py diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index 1d4fd5d4c35842..5a364bee4a0043 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -588,12 +588,16 @@ def test_cpu_count(self): 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()) _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com