diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2022-03-17 22:51:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-17 22:51:40 +0200 |
commit | 903f0a02c16240dc769a08c30e8d072a4fb09154 (patch) | |
tree | 00a9ff2477f94c7067c9daad481abde0d8d8ff3b /Lib/asyncio/tasks.py | |
parent | 33698e8ff40fcc67df3d95658e87196f8021de6f (diff) | |
download | cpython-903f0a02c16240dc769a08c30e8d072a4fb09154.tar.gz cpython-903f0a02c16240dc769a08c30e8d072a4fb09154.zip |
bpo-34790: Remove passing coroutine objects to asyncio.wait() (GH-31964)
Co-authored-by: Yury Selivanov <yury@edgedb.com>
Diffstat (limited to 'Lib/asyncio/tasks.py')
-rw-r--r-- | Lib/asyncio/tasks.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index 0b5f3226802..e876f8d002c 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -387,7 +387,7 @@ ALL_COMPLETED = concurrent.futures.ALL_COMPLETED async def wait(fs, *, timeout=None, return_when=ALL_COMPLETED): - """Wait for the Futures and coroutines given by fs to complete. + """Wait for the Futures or Tasks given by fs to complete. The fs iterable must not be empty. @@ -405,22 +405,16 @@ async def wait(fs, *, timeout=None, return_when=ALL_COMPLETED): if futures.isfuture(fs) or coroutines.iscoroutine(fs): raise TypeError(f"expect a list of futures, not {type(fs).__name__}") if not fs: - raise ValueError('Set of coroutines/Futures is empty.') + raise ValueError('Set of Tasks/Futures is empty.') if return_when not in (FIRST_COMPLETED, FIRST_EXCEPTION, ALL_COMPLETED): raise ValueError(f'Invalid return_when value: {return_when}') - loop = events.get_running_loop() - fs = set(fs) if any(coroutines.iscoroutine(f) for f in fs): - warnings.warn("The explicit passing of coroutine objects to " - "asyncio.wait() is deprecated since Python 3.8, and " - "scheduled for removal in Python 3.11.", - DeprecationWarning, stacklevel=2) - - fs = {ensure_future(f, loop=loop) for f in fs} + raise TypeError("Passing coroutines is forbidden, use tasks explicitly.") + loop = events.get_running_loop() return await _wait(fs, timeout, return_when, loop) |