Closed alcarney closed 2 years ago
Oh, so does this mean that nobody in the wild is actually using Pygls with websockets?
I could recreate the bug, but I didn't get the deprecation warning. Looking at the docs, do you think the deprecation warning is for favouring async/await?
Oh, so does this mean that nobody in the wild is actually using Pygls with websockets?
Potentially... or maybe not that many people have upgraded to pygls 0.12
yet or there's a chance this is a platform specific issue?
Pygls does fiddle with the event loop based on the platform (no idea why though... :thinking:) there's always a chance that has something to do with it....
do you think the deprecation warning is for favouring async/await?
There is a note in the changelog saying the loop
parameter is deprecated everywhere as of version 10.x
Ah yes 0.12
and other platforms, so there are other factors. Do you know what the advantages are of the websocket over the normal socket server?
Ok, so the loop
param is clearly out of the picture. And you're still looking for another way to fix the bug? I'm curious in general why the websocket server isn't started with await
, I guess it's because it would require a bit of refactoring to make all the calling parent functions async
?
Do you know what the advantages are of the websocket over the normal socket server?
The main one I'm aware of is web browsers can speak websockets natively, so you can hook up a pygls server running somewhere with some web based ui - like the Monaco Editor.
And you're still looking for another way to fix the bug?
Not currently... the loop
parameter is only deprecated so should be fine until at least v11.x
of websockets, but it is something that will break on us in the future. To be honest, this low level async stuff is beyond me at the moment, I'm assuming some deeper architectural changes will be required to fix this "properly" - maybe involving websocket's Sans-IO stuff??
I'm curious in general why the websocket server isn't started with
await
I think it's because there's nothing in start_ws
the needs to be await
ed? It seems to follow the same pattern as the other start_xxx
functions (excluding pyodide of course) where it gives the event loop some function to run and starts it going, so it's almost like it's "outside" any async code.
The main one I'm aware of is web browsers can speak websockets natively, so you can hook up a pygls server running somewhere with some web based ui - like the Monaco Editor.
Ohh yes of course, and that's potentially connected to your Pyodide work too?
Not currently... the
loop
parameter is only deprecated so should be fine until at leastv11.x
of websockets, but it is something that will break on us in the future. To be honest, this low level async stuff is beyond me at the moment, I'm assuming some deeper architectural changes will be required to fix this "properly" - maybe involving websocket's Sans-IO stuff??
Sure, working for the near term is 1000% better than not working at all! Oh, hadn't heard of Sans-IO.
I think it's because there's nothing in
start_ws
the needs to beawait
ed? It seems to follow the same pattern as the otherstart_xxx
functions (excluding pyodide of course) where it gives the event loop some function to run and starts it going, so it's almost like it's "outside" any async code.
I was wondering if an async function automatically invoked some kind of internal event loop magic in the background. But anyway, let's not worry about it for now.
and that's potentially connected to your Pyodide work too?
Not really... websockets allow you to build a more traditional client-server application with your backend either running locally on your machine or some remote server.
Pyodide lets us run the server part direct in the webpage - no separate backend required
I see, thanks for the clarification :)
Are you waiting on a review?
Yes, that would be good thanks :)
Oh, what happened here? Did I forget to review after you asked me to? I'm really sorry if that's what happened 😞
Not your fault :smile: the review happened, but I never followed it up with a merge
Oh 😅
This is an attempt at fixing #268
First this commit introduces a test that runs a websocket server in a separate thread. Note: While the test appears to work as intended, due to running the server in a separate thread I'm unable to reproduce the exact error I see in the original issue. I instead get a different error about there not being an event loop.
Next, the fix appears to work as I'm able to use websocket based servers with it, but it appears to rely on deprecated features.
Code review checklist (for code reviewer to complete)