mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +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):
|
||||
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