diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index 9a9d0d6e3cc269..ae6bf5d35f0f8a 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -362,7 +362,7 @@ async def wait(fs, *, timeout=None, return_when=ALL_COMPLETED): Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. """ - if futures.isfuture(fs) or coroutines.iscoroutine(fs): + if futures.isfuture(fs) or inspect.isawaitable(fs): raise TypeError(f"expect a list of futures, not {type(fs).__name__}") if not fs: raise ValueError('Set of coroutines/Futures is empty.') @@ -543,7 +543,7 @@ def as_completed(fs, *, timeout=None): Note: The futures 'f' are not necessarily members of fs. """ - if futures.isfuture(fs) or coroutines.iscoroutine(fs): + if futures.isfuture(fs) or inspect.isawaitable(fs): raise TypeError(f"expect an iterable of futures, not {type(fs).__name__}") from .queues import Queue # Import here to avoid circular import problem. diff --git a/Misc/NEWS.d/next/Library/2021-06-02-03-12-44.bpo-44176.-9OGEL.rst b/Misc/NEWS.d/next/Library/2021-06-02-03-12-44.bpo-44176.-9OGEL.rst new file mode 100644 index 00000000000000..1a108917f83ac5 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-06-02-03-12-44.bpo-44176.-9OGEL.rst @@ -0,0 +1 @@ +Use ``inspect.isawaitable()`` to detect if ``as_completed()``'s first parameter is awaitable \ No newline at end of file