Skip to content

[3.13] gh-130954: Fix multiprocessing test_notify_n (GH-130955) #130981

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 8, 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
21 changes: 13 additions & 8 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1609,12 +1609,10 @@ def test_notify(self):
p = self.Process(target=self.f, args=(cond, sleeping, woken))
p.daemon = True
p.start()
self.addCleanup(p.join)

p = threading.Thread(target=self.f, args=(cond, sleeping, woken))
p.daemon = True
p.start()
self.addCleanup(p.join)
t = threading.Thread(target=self.f, args=(cond, sleeping, woken))
t.daemon = True
t.start()

# wait for both children to start sleeping
sleeping.acquire()
Expand All @@ -1641,7 +1639,9 @@ def test_notify(self):

# check state is not mucked up
self.check_invariant(cond)
p.join()

threading_helper.join_thread(t)
join_process(p)

def test_notify_all(self):
cond = self.Condition()
Expand Down Expand Up @@ -1718,16 +1718,17 @@ def test_notify_n(self):
woken = self.Semaphore(0)

# start some threads/processes
workers = []
for i in range(3):
p = self.Process(target=self.f, args=(cond, sleeping, woken))
p.daemon = True
p.start()
self.addCleanup(p.join)
workers.append(p)

t = threading.Thread(target=self.f, args=(cond, sleeping, woken))
t.daemon = True
t.start()
self.addCleanup(t.join)
workers.append(t)

# wait for them to all sleep
for i in range(6):
Expand Down Expand Up @@ -1762,6 +1763,10 @@ def test_notify_n(self):
# check state is not mucked up
self.check_invariant(cond)

for w in workers:
# NOTE: join_process and join_thread are the same
threading_helper.join_thread(w)

def test_timeout(self):
cond = self.Condition()
wait = TimingWrapper(cond.wait)
Expand Down
Loading