Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-42230: Improve asyncio documentation regarding accepting sets vs iterables #23073

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,10 @@ Waiting Primitives
return_when=ALL_COMPLETED)

Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws*
set concurrently and block until the condition specified
iterable concurrently and block until the condition specified
by *return_when*.

The *aws* set must not be empty.
The *aws* iterable must not be empty.

Returns two sets of Tasks/Futures: ``(done, pending)``.

Expand Down Expand Up @@ -593,9 +593,9 @@ Waiting Primitives
.. function:: as_completed(aws, \*, loop=None, timeout=None)

Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws*
set concurrently. Return an iterator of coroutines.
iterable concurrently. Return an iterator of coroutines.
Each coroutine returned can be awaited to get the earliest next
result from the set of the remaining awaitables.
result from the iterable of the remaining awaitables.

Raises :exc:`asyncio.TimeoutError` if the timeout occurs before
all Futures are done.
Expand Down
4 changes: 2 additions & 2 deletions Lib/asyncio/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def create_task(coro, *, name=None):
async def wait(fs, *, loop=None, timeout=None, return_when=ALL_COMPLETED):
"""Wait for the Futures and coroutines given by fs to complete.

The sequence futures must not be empty.
The fs iterable must not be empty.

Coroutines will be wrapped in Tasks.

Expand Down Expand Up @@ -573,7 +573,7 @@ def as_completed(fs, *, loop=None, timeout=None):
Note: The futures 'f' are not necessarily members of fs.
"""
if futures.isfuture(fs) or coroutines.iscoroutine(fs):
raise TypeError(f"expect a list of futures, not {type(fs).__name__}")
raise TypeError(f"expect an iterable of futures, not {type(fs).__name__}")

from .queues import Queue # Import here to avoid circular import problem.
done = Queue(loop=loop)
Expand Down