adafruit / Adafruit_CircuitPython_asyncio

CIrcuitPython subset of CPython asyncio library
MIT License
28 stars 16 forks source link

add TaskGroup here or in another library #7

Open dhalbert opened 3 years ago

dhalbert commented 3 years ago

asyncio could really use a TaskGroup implementation, as provided by Trio (aka nurseries), Curio, aiotools, and EdgeDB.

TaskGroup was originally slated to be added Python as long ago as 3.8, but was held up because exception group handling was not available. However, exception groups are now being added: PEP 654, PR). Once that PEP is implemented, TaskGroup will probably follow. But the timeline for PEP 654 to go into the MicroPython core is unclear. So any TaskGroup we add will not be quite compatible, and we probably want to add it in an ancillary library (adafruit_asyncio or asynciox or xasyncio or ??).

dhalbert commented 2 years ago

TaskGroups going in to CPython 3.11: https://bugs.python.org/issue46752 https://github.com/python/cpython/pull/31270

Quattro version (not using multi-except): https://github.com/Tinche/quattro

dorinclisu commented 7 months ago

I agree it would be a good idea to support structured concurrency, as going head-on with the older asyncio primitives can get pretty messy.

Maybe the anyio lib could be helpful, as it follows the good ideas of trio but can work with the default asyncio backend.