Switch to anyio (at least internally) #44
Replies: 7 comments 16 replies
-
Typical! I just feel like I'm getting comfortable with asyncio and another paradigm shows up 😁 Without delving deeper into the details, it's hard for me to have a valid opinion, but from a surface level it sounds like a good idea. On a personal level, I'm interested in learning how to make async easier and less error-prone, as well as catching up with the state of the art. I'm wary of using asyncio-mqtt as a whipping-boy to learn it with, but at the same time, there's no better way to learn something than by actually using it. |
Beta Was this translation helpful? Give feedback.
-
I made a work-in-progress anyio port in a new branch: feat-anyio. This was the easiest for me; we can move to a new repo later. See the |
Beta Was this translation helpful? Give feedback.
-
My opinion is this library should only require asyncio. If it supports anyio, cool, but it should not require it. |
Beta Was this translation helpful? Give feedback.
-
If I am allowed to contribute to the discussion, I am opposed to the change. asyncio-mqtt makes it easy to write async MQTT applications with very few dependencies. In fact, it is just paho. I'd rather keep it that way. All other MQTT libs I found so far, are either not as mature and reliable or way larger than this lib. |
Beta Was this translation helpful? Give feedback.
-
I made my own rough take on the AnyIO Paho wrapper at the weekend. Just wanted to use it as a learning experience and I needed something for one of my projects. Now, I've registered anyio-mqtt on PyPI just so we have the name, but I'm absolutely not planning on camping on it. My interest purely lies in ending up with a decent AnyIO MQTT client, so whatever ends up being the best one can live there. If anybody starts seriously using my version from PyPI even though it has no readme/description then that's sort of on them 😅 |
Beta Was this translation helpful? Give feedback.
-
I, too, found this in search of an AnyIO based MQTT client. I took a look at several alternatives, and asyncio-mqtt had by far the best looking API. The ideal client library would be one with this API but with asynchronous internal machinery that uses AnyIO's APIs. I'm surprised nobody has create a sans-io implementation of MQTT (any version) for Python. That would be even better! I would do this work myself, but I have my hands full at the moment busy with AnyIO itself, APScheduler and other projects that have not had the attention they deserve. Perhaps something like smtpproto could serve as a basis? The MQTT protocol, even v5, isn't that complicated. If I do this, would you relinquish the |
Beta Was this translation helpful? Give feedback.
-
I have a feeling that we'll see an anyio-like interface within asyncio in the standard library in a future Python release. It's not everything that anyio is (maybe we'll never get all of it in the standard library) but it's certainly a great move towards structured concurrency. |
Beta Was this translation helpful? Give feedback.
-
Back in October 2020, I discovered anyio. It's basically a wrapper around several event loops: asyncio, trio, curio. This way, our library could cover more ground and benefit from structured concurrency.
Fill disclosure: I'm a proponent of structured concurrency. This is something that trio implements really well. In an ideal world, we would have trio in the Python standard library instead of asyncio. Unfortunately, this is not how history wanted it (trio came too late to the party). Today, asyncio is the de facto event loop implementation in Python.
Around mid-2020, I tried to take some of the ideas from structured concurrency and implement them on top of asyncio. I wanted the best of both worlds: Structured concurrency on top of the de facto event loop implementation.
Turns out I wasn't the only one with this idea: anyio beat me too it. anyio takes the ideas of structured concurrency and makes it available on top of asyncio (and other event loops).
I was really excited to find anyio and I quickly tried to port asyncio-mqtt to anyio. Unfortunately, I rant into some show stoppers in the anyio API at the time.
Recently (like 3 days ago) anyio fixed those show stoppers. The fix is still only available on master but it should land in a release soonish.
Sooo, what do you (the maintainers/community) think? Is structured concurrency a fad or the next big thing? Do we want to add anyio as a dependency (along with its dependencies)? Should we instead keep asyncio-mqtt lean and stick to the single-dependency (paho-mqtt)?
Let me know. :)
Beta Was this translation helpful? Give feedback.
All reactions