News for hackers. Stuff that matters.
Re:Python and Async Simplified (2018) by ElectricalUnion on Saturday October 22, 2022 @12:37PM (#33299801)
> await result1;

> await result2;

> await result3;

Not really, you only have *1* request in flight.

And you're waiting for them sequentially.

You need asyncio.gather ( https://docs.python.org/3/library/asyncio-task.html#asyncio.... ) if you want to run tasks concurrently.

results = await asyncio.gather(result1, result2, result3)

Re:Python and Async Simplified (2018) by samsquire on Saturday October 22, 2022 @02:09PM (#33300572)
Before the first await result1 the coroutine objects are in flight.
Re:Python and Async Simplified (2018) by Spivak on Monday October 24, 2022 @09:21AM (#33316271)
Nope, creating the coroutines doesn’t schedule them for execution. That only happens on await. Python is not eager. If you want that behavior you need to use create_task. It doesn’t work like spawning a thread and waiting on them.

From the docs: https://docs.python.org/3/library/asyncio-task.html

> Note that simply calling a coroutine will not schedule it to be executed:

Re:Python and Async Simplified (2018) by samsquire on Tuesday October 25, 2022 @07:36AM (#33329155)
Oh this is not what I expected.

I think on C# you can await threads which is similar to a join() with a return value.