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.

Author ncoghlan
Recipients Ben.Darnell, Yury.Selivanov, asvetlov, gvanrossum, martin.panter, ncoghlan, python-dev, r.david.murray, scoder, vstinner, yselivanov
Date 2015-07-03.08:27:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
"might be useful in the future" is an API design red flag that suggests to me we may not know what "good" looks like here yet. At the same time, we need something Tornado et al can use to accept the "can be used with await expressions, but doesn't implement the Awaitable protocol" types.

However, I think we can actually evaluate the consequences of two alternative designs, and decide based on the implications:

a) Add "inspect.isawaitable(obj)", tell people to use that over checking just the ABC, since an interpreter may allow more types than just Awaitable instances.

b) Add an "inspect._islegacyawaitable(obj)" API, and tell people to use "isinstance(obj, Awaitable) or inspect._islegacyawaitable(obj)", rather than just checking the ABC.

I think it makes sense to document that there are types acceptable to the "await" expression that don't implement the Awaitable protocol, just as there are types acceptable to iter() that don't implement the Iterable protocol:

>>> class Seq:
...     def __getitem__(self, idx):
...         raise IndexError
>>> iter(Seq())
<iterator object at 0x7fa6ac596748>
>>> import collections
>>> isinstance(Seq(), collections.Iterable)

In 3.6, we can add an API like "operator.getfuture()" to expose the implementation of the "retrieve a future from an awaitable" part of the await expression to Python so folks can switch to a "try it and see if it works" approach, rather than having to check with the inspect module.
Date User Action Args
2015-07-03 08:27:36ncoghlansetrecipients: + ncoghlan, gvanrossum, scoder, vstinner, r.david.murray, asvetlov, Yury.Selivanov, python-dev, Ben.Darnell, martin.panter, yselivanov
2015-07-03 08:27:36ncoghlansetmessageid: <>
2015-07-03 08:27:36ncoghlanlinkissue24400 messages
2015-07-03 08:27:36ncoghlancreate