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
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 abstractio
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 de
my question is 1st one is concurrent but 2nd one is not, how and please
correct me, what i miss and what should i know more
thank you
import asyncio
# 1st code
async def say(what, when):
await asyncio.sleep(when)
print(what)
loop = asyncio.get_event_loop()
loop.create_task(say('first h