python-lsp / python-lsp-server

Fork of the python-language-server project, maintained by the Spyder IDE team and the community
MIT License
1.95k stars 194 forks source link

Is the server-side push in Pylsp thread unsafe? #575

Open WutingjiaX opened 4 months ago

WutingjiaX commented 4 months ago

I have developed some business logic based on Pylsp (without modifying the logic related to WS). One of my business characteristics is that a didopen/didchange request may trigger a large number of server notifications. But I found that there is a probability that it will cause the client to throw a 1002 error code, leading to the closure of the link.

If I make the interval of each notification longer(like sleep 0.1s) , this problem would not have occurred.

Under circumstances where there is a large number of pushes, by printing the thread number, I have indeed found that after a certain threshold(maybe 20?), it will switch from single-threaded to multi-threaded pushing.