4 ms·
GOTO cosplaying should go away with structured concurrency (via TaskGroup) being adopted in 3.11, as pioneered by Trio. Check out anyio if you want to use them
by BiteCode_dev 5y ago
GOTO cosplaying should go away with structured concurrency (via TaskGroup) being adopted in 3.11, as pioneered by Trio.
Check out anyio if you want to use them now.
- quietbritishjim 5y agoTaskGroup in asyncio has been promised at least as far back as Python 3.8 [1]. They're still not in the draft "What's new in python 3.11" [2] and searching the web didn't return any official statements. I believe they're planned but don't believe they'll arrive any time soon. If you want to use structured concurrency now, IMO the best bet is to use Trio directly. Reading posts by the author makes it clear that every detail of the library had been extremely scrutinised, not just the API (e.g. see this long post on ctrl-C handling [3], or any number of long technical discussions on the issue tracker), so I think it's a better choice in any case. [1] https://twitter.com/1st1/status/1041855365745455104 https://twitter.com/1st1/status/1041855365745455104 [2] https://docs.python.org/3.11/whatsnew/3.11.html https://docs.python.org/3.11/whatsnew/3.11.html [3] https://vorpus.org/blog/control-c-handling-in-python-and-trio/#other-async-libraries https://vorpus.org/blog/control-c-handling-in-python-and-tri...
- BiteCode_dev 5y agoAnyio is probably a best bet to use TaskGroup IMO. You can use the trio backend if you want, after all. But it's asyncio compatible, which makes it more future proof.
- quietbritishjim 5y agoHmm, we'll just have to disagree on that one. Trio has the better API, so you might as well use that directly rather some other library that attempts to match it, even if it can/does use it under the hood. It reminds me of that xkcd about standards. It's also going to have to settle for the least common denominator to some extent even if it reimplements some parts itself (e.g. if one library implements serial ports but the other didn't, then it surely can't be in anyio). I also dispute that it's "more future proof", because you're still relying on anyio being maintained, and to me it seems to be the more obscure library.
- BiteCode_dev 5y agoThe idea is that once task groups are implemented, you can switch back to asyncio, which as more chance than Trio to be supported.