From a48e9bc64ca1cd461e29927cb39f029f6ac9bef2 Mon Sep 17 00:00:00 2001 From: Yurong He <43652751+YurongHe@users.noreply.github.com> Date: Mon, 4 Mar 2019 12:46:27 -0800 Subject: [PATCH] Fixed #4206 and #4207 open and close notebook quickly issue #4240 (#4255) * Fixed #4206 and #4207 * Check if it makes my PR run tests * Add isReady to JupyterSessionManager --- extensions/notebook/src/jupyter/jupyterSessionManager.ts | 9 +++++++-- src/sql/parts/notebook/models/notebookModel.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/extensions/notebook/src/jupyter/jupyterSessionManager.ts b/extensions/notebook/src/jupyter/jupyterSessionManager.ts index 7551728451..420159bc35 100644 --- a/extensions/notebook/src/jupyter/jupyterSessionManager.ts +++ b/extensions/notebook/src/jupyter/jupyterSessionManager.ts @@ -150,11 +150,16 @@ export class JupyterSessionManager implements nb.SessionManager { } public shutdownAll(): Promise { - return this._sessionManager.shutdownAll(); + if (this._isReady) { + return this._sessionManager.shutdownAll(); + } + return Promise.resolve(); } public dispose(): void { - this._sessionManager.dispose(); + if (this._isReady) { + this._sessionManager.dispose(); + } } } diff --git a/src/sql/parts/notebook/models/notebookModel.ts b/src/sql/parts/notebook/models/notebookModel.ts index e858194a8e..d921b14ee5 100644 --- a/src/sql/parts/notebook/models/notebookModel.ts +++ b/src/sql/parts/notebook/models/notebookModel.ts @@ -728,7 +728,7 @@ export class NotebookModel extends Disposable implements INotebookModel { for (let i = 0; i < this.notebookManagers.length; i++) { if (this.notebookManagers[i].sessionManager && this.notebookManagers[i].sessionManager.specs && this.notebookManagers[i].sessionManager.specs.kernels) { let index = this.notebookManagers[i].sessionManager.specs.kernels.findIndex(kernel => kernel.name === kernelSpec.name); - if (index >= 0) { + if (index >= 0 && this._clientSessions && this._clientSessions.length > 0) { if (this._activeClientSession) { this._oldClientSession = this._activeClientSession; }