8000 gh-130730: Fix multiprocessing test_active_children() by vstinner · Pull Request #130837 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-130730: Fix multiprocessing test_active_children() #130837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-130730: Fix multiprocessing test_active_children()
Replace a sleep with an event: sleep is not a reliable
synchronization primitive.
  • Loading branch information
vstinner committed Mar 4, 2025
commit 7e30564d45255320318eba67e2a0e11d78b17cba
12 changes: 8 additions & 4 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,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())
Expand Down
Loading
0