▲ | codethief 5 days ago | |
> Somewhat unusually, our syntax uses yield rather than await, but the behaviour is the same. Await another coroutine with yield coro. Await on multiple with yield [coro1, coro2, ...] (a 'gather' in asyncio terminology; a 'nursery' in trio terminology). Why, though? | ||
▲ | dmerrick 5 days ago | parent | next [-] | |
> The reason is that await does not offer a suspension point to an event loop (it just calls `__await__` and maybe that offers a suspension point), so if we wanted to use that syntax then we'd need to replace `yield coro` with something like await `tinyio.Task(coro)`. The traditional syntax is not worth the extra class. | ||
▲ | halfcat 5 days ago | parent | prev | next [-] | |
From the readme: > ”Ever used asyncio and wished you hadn't?” Yes, that’s me. I always found the yield-based approach to coroutines much easier to reason about. It’s just a generator function. | ||
▲ | 5 days ago | parent | prev [-] | |
[deleted] |