A higher-level operation than wait() would be gather(). But it's key to use
tasks; bare coroutines only run when you wait for them. The pattern could
be:
@coroutine
def outer():
...maybe stuff that yields...
t1 = async(inner1())
t2 = async(inner2())
...stuff that yields...
yield from gather(t1, t2) # When you need inner1/2 to be done at the
latest.
...maybe more stuff that yields...
return
On Fri, Apr 4, 2014 at 9:06 PM, Paul Tagliamonte <[email protected]> wrote:
> On Fri, Apr 04, 2014 at 09:02:36PM -0700, Guido van Rossum wrote:
> > Then use tasks. But nothing else�runs unless you yield...
>
> Yeah, I know, these are all highly IO bound operations, so it should be
> fine (they yield out enough)
>
> Anyway, I'll look into tasks, I didn't notice you could yield out
> asyncio.wait() on them out, that looks perfect.
>
> Right, thanks Guido!
> Paul
>
> > On Friday, April 4, 2014, Paul Tagliamonte <[1][email protected]>
> wrote:
> >
> > On Fri, Apr 04, 2014 at 08:56:49PM -0700, Guido van Rossum wrote:
> > > � �That's what yield from is for.
> >
> > Hey Guido,
> >
> > Yeah, but I'd rather the 'short' (not actually *that* short)
> routines to
> > run in parallel -- if I yield from each, won't that block the root
> > coroutine until the yielded coroutine will complete?
> >
> > I can run two 'long' coroutines, I'm wondering how to shuffle some
> > short-er living ones in there too
> >
> > -Paul
> >
> > --
> > #define sizeof(x) rand()
> > </paul>
> > :wq
> >
> > --
> > --Guido van Rossum (on iPad)
> >
> > References
> >
> > Visible links
> > 1. mailto:[email protected]
>
> --
> #define sizeof(x) rand()
> </paul>
> :wq
>
--
--Guido van Rossum (python.org/~guido)