-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pytest-lsp: Cancel pendining notification futures on server exit
- Loading branch information
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
`pytest-lsp` is now able to detect the situation where the server process exits while the client is waiting on a notification message and fail the test accordingly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# A server that exits mid request. | ||
import sys | ||
|
||
from lsprotocol import types | ||
from pygls.lsp.server import LanguageServer | ||
|
||
|
||
class CountingLanguageServer(LanguageServer): | ||
count: int = 0 | ||
|
||
|
||
server = CountingLanguageServer(name="completion-exit-server", version="v1.0") | ||
|
||
|
||
@server.feature("server/exit") | ||
def server_exit(*args): | ||
sys.exit(0) | ||
|
||
|
||
@server.feature(types.TEXT_DOCUMENT_COMPLETION) | ||
def on_complete(server: CountingLanguageServer, params: types.CompletionParams): | ||
server.count += 1 | ||
if server.count == 5: | ||
sys.exit(0) | ||
|
||
return [types.CompletionItem(label=f"{server.count}")] | ||
|
||
|
||
if __name__ == "__main__": | ||
server.start_io() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters