[issue43736] asyncio create_task() odd behavior

2021-04-06 Thread Yanghao Hua
Yanghao Hua added the comment: by the way, another feedback, of course, curio works the way it should, no matter where do you await ;-) Now I start to understand why David Beazley has to create curio. Python asyncio team should really really think about it carefully, please. You don't

[issue43736] asyncio create_task() odd behavior

2021-04-06 Thread Yanghao Hua
Yanghao Hua added the comment: Poking around a bit more revealed another interesting behavior and now I understand what went wrong with asyncio.create_task() :-) In the example I show, you don't have to "await t1", you only have to "await t0/t1", e.g. await on one

[issue43736] asyncio create_task() odd behavior

2021-04-06 Thread Yanghao Hua
Yanghao Hua added the comment: This unfortunately contradicts to all the other concurrency semantics I know, I have myself implemented various event-driven schedulers and none of them would behave like this. Consider an OS as the simplest example, you have a main thread that starts many child

[issue43736] asyncio create_task() odd behavior

2021-04-05 Thread Yanghao Hua
New submission from Yanghao Hua : This code runs perfectly fine with expected behavior: two tasks created, executed in an interleaved manner: from time import time from asyncio import run, create_task, sleep async def task(name, n): for i in range(n): print(f"task-{name}: