New submission from Kaleb Barrett <dev.ktbarr...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue44373>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to