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 Ben.Darnell
Recipients Ben.Darnell, Yury.Selivanov, asvetlov, gvanrossum, ncoghlan, scoder, vstinner, yselivanov
Date 2015-06-10.01:47:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1433900821.37.0.652662761253.issue24400@psf.upfronthosting.co.za>
In-reply-to
Content
> 4. While this patch addresses initial request from Ben only partially
> (generator-based coroutines still require __instancecheck__), 

A partial solution doesn't mean much to me: as long as the __instancecheck__ is sometimes necessary, I'll have to use inspect.iscoroutine all the time instead of using singledispatch with Awaitable. If anything, this just magnifies the risk of mysterious failures as things will work with async def but not yield from. I think I'd rather not have the ABC than have one with this kind of quirk.

All this checking for coroutine-ness feels very strange to me. It's anti-duck-typing: all generators have all the methods necessary to satisfy the coroutine interface, but you can't use them as coroutines without some magical indication that that's what you meant. Prior to 3.5, a coroutine was just a callable returning a generator. Now, not only must it return a generator with the special coroutine flag, the callable itself must be of the right type, which causes problems when the underlying generator function is wrapped in complex ways (https://github.com/tornadoweb/tornado/blob/2971e857104f8d02fa9107a0e13f50170eb4f30d/tornado/testing.py#L476).

Attempting to divide generators into awaitable and non-awaitable subsets is a complex solution to a problem that I'm not convinced is real. Was there a problem in practice with Python 3.4's asyncio in which people used "yield from" in a coroutine with generators that were intended to be iterators instead?
History
Date User Action Args
2015-06-10 01:47:01Ben.Darnellsetrecipients: + Ben.Darnell, gvanrossum, ncoghlan, scoder, vstinner, asvetlov, Yury.Selivanov, yselivanov
2015-06-10 01:47:01Ben.Darnellsetmessageid: <1433900821.37.0.652662761253.issue24400@psf.upfronthosting.co.za>
2015-06-10 01:47:01Ben.Darnelllinkissue24400 messages
2015-06-10 01:47:00Ben.Darnellcreate