Re: [Async-sig] concurrency mistake

2018-08-28 Thread Andrew Svetlov
Actually future is low level abstraction :) On Tue, Aug 28, 2018 at 2:31 PM Dima Tisnek wrote: > What Bret said, here (perhaps) more concise: > > async def main(): > f1 = ensure_future(say("two", 2)) > f2 = ensure_future(say("one", 1)) > # at this point both are running > await

Re: [Async-sig] concurrency mistake

2018-08-28 Thread Dima Tisnek
What Bret said, here (perhaps) more concise: async def main(): f1 = ensure_future(say("two", 2)) f2 = ensure_future(say("one", 1)) # at this point both are running await f1 await f2 Note that current event loop is automatic since Python 3.6; Futures are higher level

Re: [Async-sig] concurrency mistake

2018-08-27 Thread Brett Cannon
It's because you're awaiting on your tasks in your 2nd example, causing you to make your main() call wait until each task is complete before moving on (notice how you don't await in your calls to loop.create_task() in your 1st example). I think you want is something like: import asyncio async