-
-
Notifications
You must be signed in to change notification settings - Fork 106
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve asyncio
event loop handling
#334
Comments
I might just try migrating pygls over anyway to see if it would even work, but it's also probably worth checking to see what people's thoughts were on this 🙂 |
That's a lot of debugging! Really awesome that you're getting to the bottom of this. I think it'd be great to modernise Pygls' async code. Though of course I'm not deeply familiar with the current design decisions. The fact that you've built up so much momentum in this area now, I'm sure you'd do a great job of migrating to the high level APIs. |
Ok, as promised in #375, some thoughts on where I'd like to try and take this. JsonRPCProtocol
Servers
I'm sure I've forgotten a few things but those should be the headlines. I appreciate it will take some time to implement all of that! I was thinking we could develop most, if not all of this side-by-side with the existing stuff. That way we can incrementally ship the new approach and get feedback, then, (assuming it all works out!) deprecate and eventually remove the existing approach in a v2 release. I'm not saying I want to rewrite the world! But in cleaning up some of the inconsistencies we will wind up introducing some breaking changes - but we can try to make them as minimal as possible. Let me know your thoughts! 😄 |
I don't have any particular technical feedback here. The main thing is that I totally support a v2. All your suggestions sound really positive and that they have wider benefits to the codebase. Pygls doesn't actually have a particularly large codebase, so maybe rewriting the world isn't such a bad perspective to have! My initial reason for separating
This sounds awesome 🤓 BTW, did we ever talk about putting the client code in the |
Great thanks! Let me know if you want me to expand on anything
Possibly? 🤔 I think it's fine where it is, it's a solid base for the client side of the LSP protocol and while |
I've been struggling to track down the source of this DeprecationWarning when using
pytest-lsp
with the latestpytest-asyncio
Long story short, I think I've finally tracked it down to the following block of code.
pygls/pygls/server.py
Lines 187 to 192 in fad812a
When giving
pygls
a specificloop
to use, it goes ahead and creates a new one anyway, resulting in a second, unused event loop thatpytest-asyncio
is correctly warning about.While tweaking the code above to something like
appears to resolve the issue. I do wonder whether it's worth revisiting how
pygls
handles event loops more generally.As far as I can tell, most of pygls' event loop code was written pre-Python 3.7 where the current high level asyncio APIs didn't exist.
I guess is this is a long winded way of asking - can anyone think of any use cases that require
pygls
to stick with the current low-level APIs? I admit, despitepytest-lsp
forcing me to care more about event loops, I still don't fully understand them 😅The text was updated successfully, but these errors were encountered: