Skip to content

Commit a29ca3f

Browse files
close restart session right away (#7153) (#7161)
* close restart session right away * ignore errors on await, don't want to stop and wait for shutdown
1 parent c45ab8d commit a29ca3f

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

news/2 Fixes/6975.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Delete the old session immediatly after session restart instead of on close

src/client/datascience/jupyter/jupyterSession.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export class JupyterSession implements IJupyterSession {
4646
private statusHandler: Slot<Session.ISession, Kernel.Status> | undefined;
4747
private connected: boolean = false;
4848
private jupyterPasswordConnect: IJupyterPasswordConnect;
49-
private oldSessions: Session.ISession[] = [];
5049

5150
constructor(
5251
connInfo: IConnection,
@@ -124,8 +123,8 @@ export class JupyterSession implements IJupyterSession {
124123
if (oldStatusHandler) {
125124
oldSession.statusChanged.disconnect(oldStatusHandler);
126125
}
127-
// Don't shutdown old sessions yet. This seems to hang tests.
128-
this.oldSessions.push(oldSession);
126+
127+
this.shutdownSession(oldSession, undefined).ignoreErrors();
129128
} else {
130129
throw new Error(localize.DataScience.sessionDisposed());
131130
}
@@ -207,8 +206,7 @@ export class JupyterSession implements IJupyterSession {
207206
traceInfo(`Error waiting for restart session: ${exc}`);
208207
tryCount += 1;
209208
if (result) {
210-
// Cleanup later.
211-
this.oldSessions.push(result);
209+
this.shutdownSession(result, undefined).ignoreErrors();
212210
}
213211
result = undefined;
214212
exception = exc;
@@ -375,8 +373,6 @@ export class JupyterSession implements IJupyterSession {
375373
}
376374
if (this.session || this.sessionManager) {
377375
try {
378-
traceInfo('ShutdownSessionAndConnection - old sessions');
379-
await Promise.all(this.oldSessions.map(s => this.shutdownSession(s, undefined)));
380376
traceInfo('ShutdownSessionAndConnection - current session');
381377
await this.shutdownSession(this.session, this.statusHandler);
382378
traceInfo('ShutdownSessionAndConnection - get restart session');

0 commit comments

Comments
 (0)