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
03e4f5a2
Commit
03e4f5a2
authored
Nov 18, 2015
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Plain Diff
asyncio: Error if awaiting in parallel on the same coroutine
See
https://github.com/python/asyncio/pull/293
for details.
parents
1317c838
0728fd02
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
Lib/asyncio/coroutines.py
Lib/asyncio/coroutines.py
+7
-1
Lib/test/test_asyncio/test_pep492.py
Lib/test/test_asyncio/test_pep492.py
+20
-0
No files found.
Lib/asyncio/coroutines.py
View file @
03e4f5a2
...
...
@@ -140,7 +140,13 @@ class CoroWrapper:
if
compat
.
PY35
:
__await__
=
__iter__
# make compatible with 'await' expression
def
__await__
(
self
):
cr_await
=
getattr
(
self
.
gen
,
'cr_await'
,
None
)
if
cr_await
is
not
None
:
raise
RuntimeError
(
"Cannot await on coroutine {!r} while it's "
"awaiting for {!r}"
.
format
(
self
.
gen
,
cr_await
))
return
self
@
property
def
gi_yieldfrom
(
self
):
...
...
Lib/test/test_asyncio/test_pep492.py
View file @
03e4f5a2
...
...
@@ -203,6 +203,26 @@ class CoroutineTests(BaseTest):
self
.
loop
.
run_until_complete
(
runner
())
def
test_double_await
(
self
):
async
def
afunc
():
await
asyncio
.
sleep
(
0.1
,
loop
=
self
.
loop
)
async
def
runner
():
coro
=
afunc
()
t
=
asyncio
.
Task
(
coro
,
loop
=
self
.
loop
)
try
:
await
asyncio
.
sleep
(
0
,
loop
=
self
.
loop
)
await
coro
finally
:
t
.
cancel
()
self
.
loop
.
set_debug
(
True
)
with
self
.
assertRaisesRegex
(
RuntimeError
,
r'Cannot await.*test_double_await.*\bafunc\b.*while.*\bsleep\b'
):
self
.
loop
.
run_until_complete
(
runner
())
if
__name__
==
'__main__'
:
unittest
.
main
()
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