diff --git a/news/2 Fixes/6975.md b/news/2 Fixes/6975.md new file mode 100644 index 000000000000..a5e5fecc95f4 --- /dev/null +++ b/news/2 Fixes/6975.md @@ -0,0 +1 @@ +Delete the old session immediatly after session restart instead of on close \ No newline at end of file diff --git a/src/client/datascience/jupyter/jupyterSession.ts b/src/client/datascience/jupyter/jupyterSession.ts index 515739ed95df..8ceba8e96534 100644 --- a/src/client/datascience/jupyter/jupyterSession.ts +++ b/src/client/datascience/jupyter/jupyterSession.ts @@ -46,7 +46,6 @@ export class JupyterSession implements IJupyterSession { private statusHandler: Slot | undefined; private connected: boolean = false; private jupyterPasswordConnect: IJupyterPasswordConnect; - private oldSessions: Session.ISession[] = []; constructor( connInfo: IConnection, @@ -124,8 +123,8 @@ export class JupyterSession implements IJupyterSession { if (oldStatusHandler) { oldSession.statusChanged.disconnect(oldStatusHandler); } - // Don't shutdown old sessions yet. This seems to hang tests. - this.oldSessions.push(oldSession); + + this.shutdownSession(oldSession, undefined).ignoreErrors(); } else { throw new Error(localize.DataScience.sessionDisposed()); } @@ -207,8 +206,7 @@ export class JupyterSession implements IJupyterSession { traceInfo(`Error waiting for restart session: ${exc}`); tryCount += 1; if (result) { - // Cleanup later. - this.oldSessions.push(result); + this.shutdownSession(result, undefined).ignoreErrors(); } result = undefined; exception = exc; @@ -375,8 +373,6 @@ export class JupyterSession implements IJupyterSession { } if (this.session || this.sessionManager) { try { - traceInfo('ShutdownSessionAndConnection - old sessions'); - await Promise.all(this.oldSessions.map(s => this.shutdownSession(s, undefined))); traceInfo('ShutdownSessionAndConnection - current session'); await this.shutdownSession(this.session, this.statusHandler); traceInfo('ShutdownSessionAndConnection - get restart session');