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
c92bf83a
Commit
c92bf83a
authored
Jun 11, 2016
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #22970: asyncio: Fix inconsistency cancelling Condition.wait.
Patch by David Coles.
parent
ca2e0a48
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
1 deletion
+35
-1
Lib/asyncio/locks.py
Lib/asyncio/locks.py
+7
-1
Lib/test/test_asyncio/test_locks.py
Lib/test/test_asyncio/test_locks.py
+25
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/asyncio/locks.py
View file @
c92bf83a
...
...
@@ -329,7 +329,13 @@ class Condition(_ContextManagerMixin):
self
.
_waiters
.
remove
(
fut
)
finally
:
yield
from
self
.
acquire
()
# Must reacquire lock even if wait is cancelled
while
True
:
try
:
yield
from
self
.
acquire
()
break
except
futures
.
CancelledError
:
pass
@
coroutine
def
wait_for
(
self
,
predicate
):
...
...
Lib/test/test_asyncio/test_locks.py
View file @
c92bf83a
...
...
@@ -457,6 +457,31 @@ class ConditionTests(test_utils.TestCase):
self
.
assertFalse
(
cond
.
_waiters
)
self
.
assertTrue
(
cond
.
locked
())
def
test_wait_cancel_contested
(
self
):
cond
=
asyncio
.
Condition
(
loop
=
self
.
loop
)
self
.
loop
.
run_until_complete
(
cond
.
acquire
())
self
.
assertTrue
(
cond
.
locked
())
wait_task
=
asyncio
.
Task
(
cond
.
wait
(),
loop
=
self
.
loop
)
test_utils
.
run_briefly
(
self
.
loop
)
self
.
assertFalse
(
cond
.
locked
())
# Notify, but contest the lock before cancelling
self
.
loop
.
run_until_complete
(
cond
.
acquire
())
self
.
assertTrue
(
cond
.
locked
())
cond
.
notify
()
self
.
loop
.
call_soon
(
wait_task
.
cancel
)
self
.
loop
.
call_soon
(
cond
.
release
)
try
:
self
.
loop
.
run_until_complete
(
wait_task
)
except
asyncio
.
CancelledError
:
# Should not happen, since no cancellation points
pass
self
.
assertTrue
(
cond
.
locked
())
def
test_wait_unacquired
(
self
):
cond
=
asyncio
.
Condition
(
loop
=
self
.
loop
)
self
.
assertRaises
(
...
...
Misc/NEWS
View file @
c92bf83a
...
...
@@ -524,6 +524,9 @@ Library
_conn_lost.
Patch by Łukasz Langa.
- Issue #22970: asyncio: Fix inconsistency cancelling Condition.wait.
Patch by David Coles.
IDLE
----
...
...
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