This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: asyncio.gather should not "dedup" awaitables
Type: behavior Stage:
Components: asyncio Versions: Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, byllyfish, yselivanov
Priority: normal Keywords:

Created on 2021-08-26 05:28 by byllyfish, last changed 2022-04-11 14:59 by admin.

File name Uploaded Description Edit byllyfish, 2021-08-26 05:28
Messages (1)
msg400309 - (view) Author: William Fisher (byllyfish) Date: 2021-08-26 05:28
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

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.
Date User Action Args
2022-04-11 14:59:49adminsetgithub: 89171
2021-08-26 05:28:34byllyfishcreate