Ben Darnell added the comment:

> 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?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24400>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to