3 ms·
As an emperical point, I moved from asyncio to Trio and it was transformative. This will help bring asyncio almost up to parity but it's a pity that it's still
by quietbritishjim 4y ago
As an emperical point, I moved from asyncio to Trio and it was transformative. This will help bring asyncio almost up to parity but it's a pity that it's still possible to make tasks that don't belong to a task group - in Trio, the only way to start a task is to run it in a specified nursery. (But of course understandable for backwards compatibility.)
> this only seems to be a helper when you want to await several tasks at once
Sort of. It's a helper for if you want to run multiple tasks at once, not necessarily awaiting them. And you're definitely running multiple tasks at once otherwise you wouldn't be using asyncio in the first place.
Task groups do require you to wait for the tasks - after all, you have to start the task in a task group, and then implicit await the tasks in it (by falling off the end of the task group context block). But you can always have an outer task group representing tasks that you indent to run indefinitely in the background. In that way, task groups force you to think about when a task would cancel other tasks, representing the overall structure of your program.
- linkdd 4y agoTrio is truly great, and they implemented MultiErrors (ExceptionGroup) long before it was considered to be a PEP. I managed to make a very very simple OTP-like framework with Trio: https://linkdd.github.io/triotp/ https://linkdd.github.io/triotp/