Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
19 changes: 14 additions & 5 deletions 19 Lib/test/lock_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,21 +359,28 @@ def _check_notify(self, cond):
# construct. In particular, it is possible that this can no longer
# be conveniently guaranteed should their implementation ever change.
N = 5
ready = []
results1 = []
results2 = []
phase_num = 0
def f():
cond.acquire()
ready.append(phase_num)
cond.wait()
cond.release()
results1.append(phase_num)
cond.acquire()
ready.append(phase_num)
cond.wait()
cond.release()
results2.append(phase_num)
b = Bunch(f, N)
b.wait_for_started()
_wait()
# first wait, to ensure all workers settle into cond.wait() before
# we continue. See issues #8799 and #30727.
while len(ready) < 5:
_wait()
ready = []
self.assertEqual(results1, [])
# Notify 3 threads at first
cond.acquire()
Expand All @@ -385,9 +392,9 @@ def f():
_wait()
self.assertEqual(results1, [1] * 3)
self.assertEqual(results2, [])
# first wait, to ensure all workers settle into cond.wait() before
# we continue. See issue #8799
_wait()
# make sure all awaken workers settle into cond.wait()
while len(ready) < 3:
_wait()
# Notify 5 threads: they might be in their first or second wait
cond.acquire()
cond.notify(5)
Expand All @@ -398,7 +405,9 @@ def f():
_wait()
self.assertEqual(results1, [1] * 3 + [2] * 2)
self.assertEqual(results2, [2] * 3)
_wait() # make sure all workers settle into cond.wait()
# make sure all workers settle into cond.wait()
while len(ready) < 5:
_wait()
# Notify all threads: they are all in their second wait
cond.acquire()
cond.notify_all()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.