fix: ensure ending a session triggers listeners #2518
Merged
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.
I was looking into introducing some global session listener concept for plugin use but while doing so I found out that on closing a session we don't trigger various lifecycle listeners that we should be triggering. It appears that
Session
is deleted beforeTransport
is closed soSession.on_transport_close
and following logic is not executed.The one-line fix is to change
self._sessions
inWindowManager
fromWeakSet[Session]
toset[Session]
.I'm not sure why we are using
WeakSet
here. There could be a valid reason when this makes sense or it could be due to old convention where we've relied more on GC than on explicitly notifying when Session/SessionView/SessionBuffer are closed.(I've also left a bunch of logs that I'm of course planning to remove but those can be used to see the difference with and without this fix when closing the last file of some session, for example.)