Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork577
Add trio implementation#1628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
agronholm commentedMay 22, 2025
So, while working on my own version, I started wondering if the Another big change I had to make was the introduction of |
aaugustin commentedMay 22, 2025
@agronholm The Assembler is an implementation detail: it isn't documented in the API. It could live in the connection module. It happens to be an independent piece with medium complexity, which justifies giving it its own module. That keeps the connection module simpler. This is a personal preference in how I organize the code with no user-visible consequences. |
aaugustin commentedMay 22, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
websockets gotits own async test harness before there was one in the stdlib. The legacy implementation still uses it. I switched to I chose to stick to vanilla choices everywhere. websockets has no required dependencies, even for development. I am clearly biased by:
|
agronholm commentedMay 22, 2025
OK, so is the introduction of |
agronholm commentedMay 22, 2025
Incidentally, this is the primary reason why I steer clear of Django. |
aaugustin commentedMay 22, 2025
Mastery of pytest isn't the problem. I used it in a professional context before. I know how to configure it. Actually, I spent a lot more timedeep in the guts of the fixtures system than I ever wanted... It's simply not suitable considering my goals and constraints for this project. Keeping complexity and the amount of third-party code that I may have to understand or debug to the bare minimum ranks very high on the list. You're welcome to use it as a test runner though. |
agronholm commentedMay 22, 2025
Sure, it's your project, your rules. But I've just been thinking how much of the maintenance burden you could shed by relying on external projects rather than inventing everything yourself. Just my two cents. |
62e304c to09b9947Compareagronholm commentedMay 22, 2025
So are you going to continue with your work of adding a Trio-specific back-end? The pushes seem to indicate as much. Would you not rather let me finish my work on the AnyIO back-end? |
1051bfc to30fdd95Compareaaugustin commentedMay 22, 2025
Short, directional answer because it's 11:30pm here:
|
agronholm commentedMay 22, 2025
I don't understand. Why even suggest adding anyio AND trio back-ends when the former caters for both Trio and asyncio users? The biggest reason would be fewer parts to maintain, not more! |
aaugustin commentedMay 23, 2025
Indeed, if I finish the trio implementation within a reasonable timeframe, there's little point in an anyio implementation. As all things open-source, completion is highly dependent on everything else in my life; it isn't done until it's done :-) I see your frustration that I'm not taking advantage of anyio when you built it exactly for people like me. It's fine to disagree. However, I tried to understand where our views diverge to make sure I'm not missing something. Going straight to the point: 1/ I don't have a significant cost of maintenance for code that I control. I invest upfront in getting it right. The cost of maintenance is driven by changes in code outside of my control, whether intentional or not. asyncio is outside of my control and has been painful in this regard. trio and anyio are outside of my control; they may be less painful as asyncio but still it's more code outside of my control. (Of course anyio is under your control so you have the opposite perspective here.) 2/ This is a hobby project for me. I spend time writing code in websockets because I like coding and I don't get the opportunity to write meaningful code in my current job. Some people do crosswords; I do open-source. It's time well spent, even if others have written similar code before. I wrote an unconventional HTTP parser; it does exactly what I want and never caused problems; I found that interesting. Conversely, I get less joy of creation from diagnosing what changed in someone else's code and suddenly caused websockets to misbehave or from reviewing someone else's contribution so I'm not looking to spend more time on these activities. |
agronholm commentedMay 23, 2025
Funnily enough, you're making my point for me. If you proceed with your current plan of adding a Trio backend, you will end up with two async back-ends, either one of which may break when the upstream makes changes. But if there was only the AnyIO back-end, then |
aaugustin commentedMay 23, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This sounds like you're talking down to me. Please, let's have a constructive conversation or leave it there. I'm clear on where I disagree with you. I'm trying — and, for now, failing — to land this conversation on a respectful agreement to disagree. You're saying that using anyio will result in a lower maintenance cost. I don't buy it. I don't think there's a clear cut winner between:
(This isn't a full decision matrix; that's not my point; my point is that you have pros and cons on both sides.) It's similar building a Swift and Kotlin apps or a React Native app: both options are valid, depending on your preferences and constraints. Based on how this conversation went, it doesn't look like there's a path for smooth collaboration. Therefore, I won't consider a PR adding an anyio backend to websockets. |
agronholm commentedMay 23, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Alright, thank you for the elaborate response. At least I tried. And sorry if I sounded like I was talking down to you – it was never my intention. |
aaugustin commentedMay 23, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
No worries. Feels like we fell into a typical trap of open-source collaboration :-( If you have a WIP version of your anyio implementation somewhere, I'm genuinely interested in reading it because it will help me get a better grasp of anyio and structured concurrency (which I have no experience with). |
agronholm commentedMay 23, 2025
Here it is:https://github.com/agronholm/websockets/tree/anyio |
c224f28 to1c346bdCompare4ca3810 to56fde96Compare3341352 to6f7bf08Compareaaugustin commentedAug 9, 2025
Green build. Woohoo. Still a few fixes + full proof-reading necessary. |
519dace toc726348Compareaaugustin commentedOct 21, 2025
The first six commits were merged in#1669. |
fjarri commentedOct 24, 2025
Just curious, why |
aaugustin commentedOct 25, 2025
There's an extensive discussion of this question with the author of anyio in the discussion above. The very short version is:
|
aaugustin commentedOct 25, 2025
Also, since this is a hobby project, when two paths that are likely to lead to a similar result, "which one I'll be happiest to implement and maintain" is the decisive factor. Implementation cost is fairly irrelevant as I'm not interested in minimizing the time I spend enjoying my hobby :-) |
vfazio commentedNov 3, 2025
Just strolling through MRs as we look at updating our dependencies.. I remember one of my coworkers bringing up anyio integration before and the issue got closed:#969 |
aaugustin commentedNov 3, 2025
Yes, theconclusion on that issue still stands. The only difference since then is that I've rewritten the asyncio implementation on top of the Sans-I/O implementation. |
aaugustin commentedNov 3, 2025
The other difference, obviously, is that I've written a trio implementation. I'm now slicing it into smaller patches for reviewability. I still have to decide on the top-level API, as there's tension between "consistency with trio" and "consistency with websockets". |
Also uniformize code & tests with other implementations.
No description provided.