mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-24638: Improve the error message in asyncio.ensure_future() (#12848)
This commit is contained in:
parent
ceb842e155
commit
4737b923df
2 changed files with 11 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue