Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be more careful about sessioncontext kernelChanged and sessionChanged signal emissions #7694

Merged
merged 3 commits into from Dec 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/apputils/src/sessioncontext.tsx
Expand Up @@ -512,6 +512,8 @@ export class SessionContext implements ISessionContext {
return;
}
this._isDisposed = true;
this._disposed.emit();

if (this._session) {
if (this.kernelPreference.shutdownOnDispose) {
// Fire and forget the session shutdown request
Expand All @@ -531,7 +533,6 @@ export class SessionContext implements ISessionContext {
this._busyDisposable.dispose();
this._busyDisposable = null;
}
this._disposed.emit();
Signal.clearData(this);
}

Expand Down Expand Up @@ -765,9 +766,11 @@ export class SessionContext implements ISessionContext {
private _onSessionDisposed(): void {
if (this._session) {
this._session.dispose();
const oldValue = this._session;
this._session = null;
const newValue = this._session;
this._sessionChanged.emit({ name: 'session', oldValue, newValue });
}
this._session = null;
this._terminated.emit(undefined);
}

/**
Expand Down Expand Up @@ -873,7 +876,6 @@ export class SessionContext implements ISessionContext {
private _initializing = false;
private _initPromise = new PromiseDelegate<boolean>();
private _isReady = false;
private _terminated = new Signal<this, void>(this);
private _kernelChanged = new Signal<
this,
Session.ISessionConnection.IKernelChangedArgs
Expand Down
24 changes: 13 additions & 11 deletions packages/console-extension/src/index.ts
Expand Up @@ -162,17 +162,19 @@ async function activateConsole(
// Handle state restoration.
void restorer.restore(tracker, {
command: CommandIDs.create,
args: widget => ({
path: widget.content.console.sessionContext.session?.path,
name: widget.content.console.sessionContext.session?.name,
kernelPreference: {
name: widget.content.console.sessionContext.kernelPreference.name,
language:
widget.content.console.sessionContext.kernelPreference.language
}
}),
name: widget =>
widget.content.console.sessionContext.session?.path ?? UUID.uuid4(),
args: widget => {
const {
path,
name,
kernelPreference
} = widget.content.console.sessionContext;
return {
path,
name,
kernelPreference: { ...kernelPreference }
};
},
name: widget => widget.content.console.sessionContext.path ?? UUID.uuid4(),
when: manager.ready
});

Expand Down
11 changes: 9 additions & 2 deletions packages/services/src/session/default.ts
Expand Up @@ -206,8 +206,15 @@ export class SessionConnection implements Session.ISessionConnection {
}
this._isDisposed = true;
this._disposed.emit();
this._kernel?.dispose();
this._kernel = null;

if (this._kernel) {
this._kernel.dispose();
let oldValue = this._kernel;
this._kernel = null;
let newValue = this._kernel;
this._kernelChanged.emit({ name: 'kernel', oldValue, newValue });
}

Signal.clearData(this);
}

Expand Down