Repository navigation
Reset readiness events so start_server can be entered more than once - #169
Open
Puliuvarthi.Mahesh (MaheshPulivarthi18) wants to merge 1 commit into
Conversation
The readiness asyncio.Event objects stayed set after the first session and could be bound to a stale event loop, so a second start_server() on the same instance returned None. Recreate the events before startup and after shutdown in the clangd, JDTLS, gopls, OmniSharp, rust-analyzer, Solargraph and TypeScript servers. Add a restart test for the TypeScript server.
Author
|
@microsoft-github-policy-service agree |
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #101.
Problem
Entering
start_server()a second time on the same language server instance returnedNonefor requests such as hover. The readinessasyncio.Eventobjects (server_ready,completions_available, etc.) are created once and stay set after the first session. The second session therefore starts with stale state.SyncLanguageServeralso runs each session on a new event loop, so reusing an oldEvent(or callingclear()on it) risks a 'bound to a different event loop' error.Change
In the seven servers that keep readiness events (clangd, Eclipse JDTLS, gopls, OmniSharp, rust-analyzer, Solargraph, TypeScript), the events are now recreated with a fresh
asyncio.Event()before the server process starts. They are recreated again in thefinallyblock after shutdown, so no set event remains between sessions.I added
tests/multilspy/test_multilspy_restart.py. It entersstart_server()twice on oneSyncLanguageServerfor TypeScript and checks that both sessions return the same definition result. It also checks that the events are unset and replaced after the first session.For the reviewer
clear(), because of the event loop binding described above.Testing
New test
tests/multilspy/test_multilspy_restart.py: oneSyncLanguageServer(TypeScript) entered twice withwith lsp.start_server().server_readyis still set:1 passed in 3.78stest_multilspy_python.py,test_sync_multilspy_python.py,test_multilspy_typescript.py,test_sync_file_thread.pyandtest_adapter_notifications.pygave 18 passed before the change, and 19 passed after it (the 18 plus the new test). They were run with.venv/binonPATHsojedi-language-serveris found.