Paul,

I recommend that you take a step back and look at it from a different angle.

If you have a coroutine that is waiting for you to tell it to run again,
you should use a Future. The coroutine should use "yield from" on it, and
in the other code, when you are ready to make it run, you call set_result()
(or set_exception()) on that same Future.

That's all there is to it!

Good luck,

--Guido


On Thu, Apr 24, 2014 at 5:32 PM, Paul Sokolovsky <[email protected]> wrote:

> Hello,
>
> This must be FAQ, but: 1) google can't get search results right; 2) people
> gotta ask that again, again, and again, so here it goes.
>
> Why Task objects in asyncio are not callable? Just studying asyncio, it
> becomes clear that it's core is loop which runs callbacks from a queue. So,
> how do we integrate coroutines via generators into that? Obvious, we add an
> adapter object which translates call protocol into generator protocol,
> voila.
>
> Now, why that undocumented _step() method, worse, why is it scheduled to
> be called in *Task constructor*? How just creating a task object makes it
> scheduled? Why are users denied ability to schedule Tasks as they see fit?
> In general, why all this tight coupledness between event loop and Tasks?
>
> Where this comes from: I'm looking for the simplest possible way to
> schedule a coroutine to be run. run_until_complete(), asyncio.wait() - too
> complicated and bloated ways for such a simple task (and that's what
> asyncio docs give in examples).
>
> Thanks.
>
>


-- 
--Guido van Rossum (python.org/~guido)

Reply via email to