Skip to content

Commit b62b9ae

Browse files
vstinnermiss-islington
authored andcommitted
pythongh-130730: Fix multiprocessing test_active_children() (pythonGH-130837)
Replace a sleep with an event: sleep is not a reliable synchronization primitive. (cherry picked from commit 3dd3675) Co-authored-by: Victor Stinner <[email protected]>
1 parent a115480 commit b62b9ae

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,12 +588,16 @@ def test_cpu_count(self):
588588
def test_active_children(self):
589589
self.assertEqual(type(self.active_children()), list)
590590

591-
p = self.Process(target=time.sleep, args=(DELTA,))
591+
event = self.Event()
592+
p = self.Process(target=event.wait, args=())
592593
self.assertNotIn(p, self.active_children())
593594

594-
p.daemon = True
595-
p.start()
596-
self.assertIn(p, self.active_children())
595+
try:
596+
p.daemon = True
597+
p.start()
598+
self.assertIn(p, self.active_children())
599+
finally:
600+
event.set()
597601

598602
p.join()
599603
self.assertNotIn(p, self.active_children())

0 commit comments

Comments
 (0)