[Python-ideas] The async API of the future: yield-from
Calvin Spealman
ironfroggy at gmail.com
Tue Oct 16 17:18:22 CEST 2012
On Mon, Oct 15, 2012 at 8:55 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Calvin Spealman wrote:
>
>> I'm still -1 on delegating control to subgenerators with yield-from,
>> versus having the scheduler just deal with them directly.
>
> Do you mean to *disallow* using yield-from for this, or just
> not to encourage it?
>
> I don't see how you *could* disallow it; there's no way for
> the scheduler to know whether one of the generators it's
> handling is delegating using yield-from.
>
> I also can't see any reason you would want to discourage it.
> Given that yield-from exists, it's an obvious thing to do.
I have since changed my position slightly. I don't want to disallow it, no.
I don't want to discourage, no. But, I do think *both* are useful.
I think "yield from" is the obvious way to "call" between tasks, but that
there are other cases when we want to spawn a task to begin without
blocking our task, and that "yield" should be used here. We should be
table to simply yield a task to tell the scheduler to start it,
possibly getting a Future in return which we can use to get the
eventual result. This may make it easier to do multiple sub-tasks
together. We might yield N tasks, and then "yield from wait(futures)"
to wait for them all to complete.
> --
> Greg
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
--
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
More information about the Python-ideas
mailing list