mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-130730: Fix multiprocessing test_active_children() (#130837)
Replace a sleep with an event: sleep is not a reliable synchronization primitive.
This commit is contained in:
parent
885c3d126f
commit
3dd3675492
1 changed files with 8 additions and 4 deletions
|
@ -589,12 +589,16 @@ class _TestProcess(BaseTestCase):
|
||||||
def test_active_children(self):
|
def test_active_children(self):
|
||||||
self.assertEqual(type(self.active_children()), list)
|
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())
|
self.assertNotIn(p, self.active_children())
|
||||||
|
|
||||||
p.daemon = True
|
try:
|
||||||
p.start()
|
p.daemon = True
|
||||||
self.assertIn(p, self.active_children())
|
p.start()
|
||||||
|
self.assertIn(p, self.active_children())
|
||||||
|
finally:
|
||||||
|
event.set()
|
||||||
|
|
||||||
p.join()
|
p.join()
|
||||||
self.assertNotIn(p, self.active_children())
|
self.assertNotIn(p, self.active_children())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue