Skip to content

[3.13] gh-130737: Fix multiprocessing test_notify() (GH-130797) #130802

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 3, 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
14 changes: 5 additions & 9 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1577,14 +1577,13 @@ def f(cls, cond, sleeping, woken, timeout=None):
cond.release()

def assertReachesEventually(self, func, value):
for i in range(10):
for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
try:
if func() == value:
break
except NotImplementedError:
break
time.sleep(DELTA)
time.sleep(DELTA)

self.assertReturnsIfImplemented(value, func)

def check_invariant(self, cond):
Expand Down Expand Up @@ -1618,26 +1617,23 @@ def test_notify(self):
sleeping.acquire()

# check no process/thread has woken up
time.sleep(DELTA)
self.assertReturnsIfImplemented(0, get_value, woken)
self.assertReachesEventually(lambda: get_value(woken), 0)

# wake up one process/thread
cond.acquire()
cond.notify()
cond.release()

# check one process/thread has woken up
time.sleep(DELTA)
self.assertReturnsIfImplemented(1, get_value, woken)
self.assertReachesEventually(lambda: get_value(woken), 1)

# wake up another
cond.acquire()
cond.notify()
cond.release()

# check other has woken up
time.sleep(DELTA)
self.assertReturnsIfImplemented(2, get_value, woken)
self.assertReachesEventually(lambda: get_value(woken), 2)

# check state is not mucked up
self.check_invariant(cond)
Expand Down
Loading