Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
32cb968a
Commit
32cb968a
authored
Jun 23, 2017
by
Serhiy Storchaka
Committed by
GitHub
Jun 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-30727: Fix a race condition in test_threading. (#2334)
parent
c8fb58bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
Lib/test/lock_tests.py
Lib/test/lock_tests.py
+14
-5
No files found.
Lib/test/lock_tests.py
View file @
32cb968a
...
...
@@ -461,21 +461,28 @@ class ConditionTests(BaseTestCase):
# 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
)
result
=
cond
.
wait
()
cond
.
release
()
results1
.
append
((
result
,
phase_num
))
cond
.
acquire
()
ready
.
append
(
phase_num
)
result
=
cond
.
wait
()
cond
.
release
()
results2
.
append
((
result
,
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
.
clear
()
self
.
assertEqual
(
results1
,
[])
# Notify 3 threads at first
cond
.
acquire
()
...
...
@@ -487,9 +494,9 @@ class ConditionTests(BaseTestCase):
_wait
()
self
.
assertEqual
(
results1
,
[(
True
,
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
)
...
...
@@ -500,7 +507,9 @@ class ConditionTests(BaseTestCase):
_wait
()
self
.
assertEqual
(
results1
,
[(
True
,
1
)]
*
3
+
[(
True
,
2
)]
*
2
)
self
.
assertEqual
(
results2
,
[(
True
,
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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment