Skip to content

asyncio.wait should not check for emptiness of iterable by calling its __bool__ method #149480

@jonathandung

Description

@jonathandung

Bug report

Bug description:

asyncio.wait is documented to accept an iterable of non-coroutine awaitable objects in its docstring:

The fs iterable must not be empty.

and the python docs page:

The aws iterable must not be empty.

We notice a discrepancy: The parameter is called fs in asyncio.tasks:

async def wait(fs, *, timeout=None, return_when=ALL_COMPLETED)

but aws in the docs. It should be aws for 'awaitables'.

Besides, the following line exists in its source:

if not fs:
    raise ValueError('Set of Tasks/Futures is empty.')

This may be error-prone for iterables implementing a __bool__ method with different semantics. This check should either be documented or abolished.

See the source and the docs.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-asynciotype-featureA feature request or enhancement

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions