For a group of tasks, use a nursery.
Edit: correction
For a group of tasks, use a nursery.
Edit: correction
What do you get? For starters, Ctrl-C/KeyboardInterrupt just works. By restricting the design space, you end up with much more intuitive designs.
Obligatory Structured Concurrency essay link: https://vorpus.org/blog/notes-on-structured-concurrency-or-g...
I recommend giving it a read.
I don’t see much more useful here than understanding the asyncio primitives and available synchronization abstractions, just a different API mostly overlapping the same need
To be clear, trio also has more than one way to wait for a task - any await is the same (e.g. `await trio.sleep(N)` (e.g. `await asyncio.sleep(N)`). I think maybe you’re getting at waiting for a group of tasks?
For a theoretical take see
https://vorpus.org/blog/notes-on-structured-concurrency-or-g...
To be precise, to wait for a task its actually just await. Theres no ensure_future etc. Trio doesn't have the concept of futures or promises at all, and await f() is treated as a single piece of syntax, so in practice it doesn't have "awaitables" either.
I'm not sure it's totally novel though. For instance, C# has AsParallel() extensions which let you run collection operations in parallel (similar functions in Haskell too). It has the same black box behaviour described by the article, and there's an equivalence between direct control flow in code and indirect control flow reified as a data structure, ie. Haskell's case that lazy evaluation and lists are the only control flow construct you need.
Still, it's an interesting imperative incarnation of the idea!