Fix issue with Session not being garbage collected#2801
Merged
Conversation
Member
Author
|
Switched to manual caching for diagnostic identifiers. |
jwortmann
reviewed
Mar 10, 2026
| # Have to do this on the main thread, since __init__ and __del__ are invoked on the main thread too | ||
| self._cleanup() | ||
| self._setup() | ||
| get_diagnostics_identifiers.cache_clear() |
Member
There was a problem hiding this comment.
_reset is called when either the syntax or the URI of the view changes:
Lines 1128 to 1129 in e74ce6b
In that case the DocumentSelector might not match anymore for the diagnostic provider(s). That is the reason why we need to clear the cache here.
For the manual cache, you could also just pop the value for this particular view from the cache instead. That would even be more efficient than clearing the entire cache.
jwortmann
reviewed
Mar 10, 2026
✅ Deploy Preview for sublime-lsp ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-authored-by: jwortmann <jwortmann@outlook.com>
jwortmann
approved these changes
Mar 10, 2026
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.
Sessions were not being garbage collected for two reasons:
request_handler/notification_handlerdecorators, we've stored reference to methods onself. Since methods have hard reference toselfthat created a cycle. Store only mapping from handler name tom_*handler and use that for calling the right function whenm_*method is called.get_diagnostics_identifiersfunction useslru_cachedecorator which stores reference toSession. We need to clear the cache when session is destroyed.This is not a proper fix since it clears the whole cache instead of only caches related to ended session but I don't have time now to investigate it further.Addressed by switching to manual caching.For testing one can add
in
Sessionto verify that session is destroyed on last file in the window being closed.