mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
[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 3dd3675492
)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
a115480f71
commit
22d729cf5d
1 changed files with 8 additions and 4 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue