[issue45008] asyncio.gather should not "dedup" awaitables

William Fisher report at bugs.python.org
Thu Aug 26 01:28:34 EDT 2021


New submission from William Fisher <william.w.fisher at gmail.com>:

asyncio.gather uses a dictionary to de-duplicate futures and coros. However, this can lead to problems when
you pass an awaitable object (implements __await__ but isn't a future or coro).

1. Two or more awaitables may compare for equality/hash, but still expect to produce different results (See the RandBits class in gather_test.py)

2. If an awaitable doesn't support hashing, asyncio.gather doesn't work.

Would it be possible for non-future, non-coro awaitables to opt out of the dedup logic?

The attached file shows an awaitable RandBits class. Each time you await it, you should get a different
result. Using gather, you will always get the same result.

----------
components: asyncio
files: gather_test.py
messages: 400309
nosy: asvetlov, byllyfish, yselivanov
priority: normal
severity: normal
status: open
title: asyncio.gather should not "dedup" awaitables
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file50236/gather_test.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45008>
_______________________________________


More information about the Python-bugs-list mailing list