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
4737b923
Commit
4737b923
authored
May 03, 2019
by
Zackery Spytz
Committed by
Andrew Svetlov
May 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-24638: Improve the error message in asyncio.ensure_future() (#12848)
parent
ceb842e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
Lib/asyncio/tasks.py
Lib/asyncio/tasks.py
+2
-1
Lib/test/test_asyncio/test_tasks.py
Lib/test/test_asyncio/test_tasks.py
+9
-0
No files found.
Lib/asyncio/tasks.py
View file @
4737b923
...
...
@@ -628,7 +628,8 @@ def ensure_future(coro_or_future, *, loop=None):
return
task
elif
futures
.
isfuture
(
coro_or_future
):
if
loop
is
not
None
and
loop
is
not
futures
.
_get_loop
(
coro_or_future
):
raise
ValueError
(
'loop argument must agree with Future'
)
raise
ValueError
(
'The future belongs to a different loop than '
'the one specified as the loop argument'
)
return
coro_or_future
elif
inspect
.
isawaitable
(
coro_or_future
):
return
ensure_future
(
_wrap_awaitable
(
coro_or_future
),
loop
=
loop
)
...
...
Lib/test/test_asyncio/test_tasks.py
View file @
4737b923
...
...
@@ -236,6 +236,15 @@ class BaseTaskTests:
with
self
.
assertRaises
(
TypeError
):
asyncio
.
ensure_future
(
'ok'
)
def
test_ensure_future_error_msg
(
self
):
loop
=
asyncio
.
new_event_loop
()
f
=
self
.
new_future
(
self
.
loop
)
with
self
.
assertRaisesRegex
(
ValueError
,
'The future belongs to a '
'different loop than the one specified as '
'the loop argument'
):
asyncio
.
ensure_future
(
f
,
loop
=
loop
)
loop
.
close
()
def
test_get_stack
(
self
):
T
=
None
...
...
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