[New-bugs-announce] [issue41813] Clarify specification of object.__await__

Paolo Lammens report at bugs.python.org
Sat Sep 19 09:57:34 EDT 2020


New submission from Paolo Lammens <lammenspaolo at gmail.com>:

The current specification of object.__await__ is just:

> `object.__await__(self)`
>
> Must return an iterator. Should be used to implement awaitable objects. For instance, `asyncio.Future` implements this method to be compatible with the await expression.

This is pretty vague leaves the doubt of *what* objects is the iterator expected to yield (and how the value of the yielded object affects the management of the awaitable object).

Although the vagueness is probably on purpose (since this isn't tied to any particular event loop implementation, so it can be an arbitrary iterable), I think it's worthwhile adding a note clarifying this aspect.

I originally posed this question on StackOverflow: https://stackoverflow.com/q/63964011/6117426

----------
assignee: docs at python
components: Documentation
messages: 377166
nosy: docs at python, plammens
priority: normal
severity: normal
status: open
title: Clarify specification of object.__await__

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


More information about the New-bugs-announce mailing list