[Python-ideas] The async API of the future: yield-from
Guido van Rossum
guido at python.org
Mon Oct 15 01:28:56 CEST 2012
On Sun, Oct 14, 2012 at 3:55 PM, Ben Darnell <ben at bendarnell.com> wrote:
> Ah, OK. I was mistaken about the "first yield" part, but the rest
> stands. The problem is that as soon as task1 blocks on IO, the entire
> current task (which includes outer(), par(), and both children) gets
> unscheduled. no part of task2 gets scheduled until it gets yielded
> from, because the scheduler can't see it until then.
Ah, yes. I had forgotten that the whole stack (at least all frames
currently blocked in yield-from) is suspended.
I really hope that Greg has a working implementation of par().
> The good and bad parts of this proposal both stem from the fact that
> yield from is very similar to just inlining everything together. This
> gives you the exception handling semantics that you expect from
> synchronous code, but it means that the scheduler can't distinguish
> between subtasks; you have to explicitly schedule them as top-level
I'm beginning to see that. Thanks for helping me form my intuition
about how this stuff works!
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas