[New-bugs-announce] [issue44373] make Event and Awaitable

Kaleb Barrett report at bugs.python.org
Thu Jun 10 03:34:22 EDT 2021


New submission from Kaleb Barrett <dev.ktbarrett at gmail.com>:

Following on from https://bugs.python.org/issue33544. I don't agree with the original suggestion to deprecate the wait() method on Events, but I do agree that Event should be made Awaitable. Doing so would make code more expressive, but more importantly improve the ability to use Events with generic code that can already handles the other Awaitable types in asyncio.

There were generally neutral takes on providing both __await__ and wait, besides Yury Selivanov who implied it was complex (???). I just tried the below, but maybe I'm missing something?


class AwaitableEvent(Awaitable[None], Event):

    def __await__(self) -> None:
        yield from self.wait().__await__()

    __iter__ = __await__

----------
components: asyncio
messages: 395511
nosy: asvetlov, ktbarrett, yselivanov
priority: normal
severity: normal
status: open
title: make Event and Awaitable
versions: Python 3.10

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


More information about the New-bugs-announce mailing list