diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py index ccb30b429..41c23796d 100644 --- a/plugin/core/sessions.py +++ b/plugin/core/sessions.py @@ -1304,6 +1304,9 @@ def __getattr__(self, name: str) -> Any: return attr raise AttributeError(name) + def __del__(self) -> None: + print('[Session] __del__', self.config.name) + # TODO: Create an assurance that the API doesn't change here as it can be used by plugins. def get_workspace_folders(self) -> list[WorkspaceFolder]: return self._workspace_folders @@ -2245,6 +2248,7 @@ def m___progress(self, params: ProgressParams) -> None: # --- shutdown dance ----------------------------------------------------------------------------------------------- def end_async(self) -> None: + print('[Session] end_async', self.exiting) # TODO: Ensure this function is called only from the async thread if self.exiting: return @@ -2266,12 +2270,14 @@ def end_async(self) -> None: watcher.destroy() self._dynamic_file_watchers = {} self.state = ClientStates.STOPPING + print('[Session] Sending shutdown') self.send_request_async(Request.shutdown(), self._handle_shutdown_result, self._handle_shutdown_result) def _handle_shutdown_result(self, _: Any) -> None: self.exit() def on_transport_close(self, exit_code: int, exception: Exception | None) -> None: + print('[Session] on_transport-close') self.exiting = True self.state = ClientStates.STOPPING self.transport = None @@ -2356,6 +2362,7 @@ def send_error_response(self, request_id: Any, error: Error) -> None: def exit(self) -> None: self.send_notification(Notification.exit()) try: + print('[Session] Closing transport') self.transport.close() # type: ignore except AttributeError: pass diff --git a/plugin/core/transports.py b/plugin/core/transports.py index b0e91f89c..48d83c64a 100644 --- a/plugin/core/transports.py +++ b/plugin/core/transports.py @@ -188,6 +188,7 @@ def _end(self, exception: Exception | None) -> None: def invoke() -> None: callback_object = self._callback_object() + print('[ProcessTransport] end Transport', callback_object) if callback_object: callback_object.on_transport_close(exit_code, exception) diff --git a/plugin/core/windows.py b/plugin/core/windows.py index 29abdea97..d6114f477 100644 --- a/plugin/core/windows.py +++ b/plugin/core/windows.py @@ -75,7 +75,7 @@ class WindowManager(Manager, WindowConfigChangeListener): def __init__(self, window: sublime.Window, workspace: ProjectFolders, config_manager: WindowConfigManager) -> None: self._window = window self._config_manager = config_manager - self._sessions: WeakSet[Session] = WeakSet() + self._sessions: set[Session] = set() self._workspace = workspace self._pending_listeners: deque[AbstractViewListener] = deque() self._listeners: WeakSet[AbstractViewListener] = WeakSet() @@ -341,6 +341,7 @@ def handle_message_request(self, session: Session, params: Any, request_id: Any) MessageRequestHandler(view, session, request_id, params, session.config.name).show() def restart_sessions_async(self, config_name: str | None = None) -> None: + print('[WindowManager] restart_sessions_async') self._end_sessions_async(config_name) listeners = list(self._listeners) self._listeners.clear() @@ -348,6 +349,7 @@ def restart_sessions_async(self, config_name: str | None = None) -> None: self.register_listener_async(listener) def _end_sessions_async(self, config_name: str | None = None) -> None: + print('[WindowManager] end_session', config_name) sessions = list(self._sessions) for session in sessions: if config_name is None or config_name == session.config.name: @@ -384,6 +386,7 @@ def should_ignore_diagnostics(self, uri: DocumentUri, configuration: ClientConfi return None def on_post_exit_async(self, session: Session, exit_code: int, exception: Exception | None) -> None: + print('[WindowManager] on_post_exit_async', session.config.name) self._sessions.discard(session) for listener in self._listeners: listener.on_session_shutdown_async(session) diff --git a/plugin/documents.py b/plugin/documents.py index 901d81fda..84d1baf7e 100644 --- a/plugin/documents.py +++ b/plugin/documents.py @@ -241,6 +241,7 @@ def on_session_initialized_async(self, session: Session) -> None: def on_session_shutdown_async(self, session: Session) -> None: removed_session = self._session_views.pop(session.config.name, None) + print('[DocumentListener] on_session_shutdown_async', removed_session) if removed_session: removed_session.on_before_remove() if not self._session_views: @@ -1006,6 +1007,7 @@ def run_sync() -> None: sublime.set_timeout(run_sync) def _clear_session_views_async(self) -> None: + print('[DocumentListener] _clear_session_views_async') session_views = self._session_views def clear_async() -> None: