[Python-ideas] The async API of the future: yield-from

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Oct 16 02:24:15 CEST 2012


I've just had another thought I'd like to mention
concerning the way we think about subtasks.

There's actually a subtle difference between invoking
a subgenerator using yield-from on the one hand, and
spawning it as a separate task and then waiting for
it on the other.

When you call a subgenerator using yield-from, a switch
to another task can't occur until that subgenerator or
something it calls reaches a yield.

But (at least the way my scheduler currently works),
if you spawn it as a separate task and then block
waiting for it to complete, other tasks can run
immediately, before the subtask has even started.

If you're relying on knowing where the yields can
occur, this difference could be important. So I think
the distinction between calling and spawning subtasks
needs to be maintained. This means that spawning must
be something you request explicitly in some way.

-- 
Greg



More information about the Python-ideas mailing list