|
|
|
|
|
by ptx
1225 days ago
|
|
> There is no reason a scheduler could not be totally lazy and only execute the coroutine once awaited. Isn't the point of create_task (which is what the article is about) to launch concurrent tasks without immediately awaiting them? The example in the docs [1] wouldn't work (in the stated manner) if the task didn't start until it was awaited. > At least he bothered to make note of TaskGroups [...] Yep, that's all there was to it. That only works on Python 3.11, which was released just a few months ago. Debian still uses 3.9, for example, so the TaskGroups solution can't be used everywhere yet. [1] https://docs.python.org/3/library/asyncio-task.html#coroutin... |
|
Yes, TaskGroups are a recent addition. If you can't use Python 3.11 for whatever reason, there is also the clearly written code sample at the bottom of the create_task documentation, which the author did not bother to mention. Probably didn't make it that far.