[Python-Dev] PEP 479 and asyncio
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Nov 28 10:12:05 CET 2014
Guido van Rossum wrote:
> The issue here is that asyncio only interprets StopIteration as
> returning from the generator (with a possible value), while a Trollius
> coroutine must use "raise Return(<value>)" to specify a return value;
> this works as long as Return is a subclass of StopIteration, but PEP 479
> will break this by replacing the StopIteration with RuntimeError.
I don't understand. If I'm interpreting PEP 479 correctly, in
'x = yield from foo', a StopIteration raised by foo.__next__()
doesn't get turned into a RuntimeError; rather it just stops the
sub-iteration as usual and its value attribute gets assigned to x.
As long as a Trollius coroutine behaves like something implementing
the iterator protocol, it should continue to work fine with
Return as a subclass of StopIteration.
Or is there something non-obvious about Trollius that I'm
missing?
--
Greg
More information about the Python-Dev
mailing list