openlawlibrary / pygls

A pythonic generic language server
https://pygls.readthedocs.io/en/latest/
Apache License 2.0
568 stars 103 forks source link

Wb sockets protocol specification deviated #219

Open npradeep357 opened 2 years ago

npradeep357 commented 2 years ago

Hi,

According to Web Sockets specification, there can be 'n' clients which needs 'n' pygls instances. According to the current implementation, only once connection can be supported properly for one pygls process. And it is not practical to start a new WS process every time I need attach a new client.

This can be enhanced (or in fact rectified) by simply providing new pygls instance (object) for every new connection instead of pointing to the same self.lsp instance. ref: code

we can maintain a list of tuples (websocket, pygls instance) for every new connection and should be managed by the same.

More over this cannot be handled in the same way TCP or IO as there will be only one instance per process in these cases, but in WS case, we need multiple in single process.

npradeep357 commented 2 years ago

more details over here: jedi-language-server issues #173

tombh commented 1 year ago

Sorry for the late reply. Could you give a use case or example of this issue? I don't doubt its usefulness, just want to understand it better. Thank you.

npradeep357 commented 1 year ago

Sorry for the late reply. Could you give a use case or example of this issue? I don't doubt its usefulness, just want to understand it better. Thank you.

Currently this only supports one live WS client at any point. To use this with multiple clients in parallel, you need to create multiple WS servers which is not ideal.

Problem is that the WS server is tightly coupled with pygls object/instance. Separate this and make sure that multiple pygls instances can be called from WS server.