Skip to content

Allow interrupting the kernel more than once #11184

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

Merged
merged 1 commit into from
Apr 15, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/10356.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cancelling the prompt to restart the kernel should not leave the toolbar buttons disabled.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there's still one more must fix for april that we have to finish

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you are referring to Save Notebooks, if thats it then I've submitted a PR for that.

1 change: 1 addition & 0 deletions news/2 Fixes/10587.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow interrupting the kernel more than once.
48 changes: 31 additions & 17 deletions src/client/datascience/interactive-common/interactiveBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,29 +381,40 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp
}

if (this._notebook && !this.restartingKernel) {
if (await this.shouldAskForRestart()) {
// Ask the user if they want us to restart or not.
const message = localize.DataScience.restartKernelMessage();
const yes = localize.DataScience.restartKernelMessageYes();
const dontAskAgain = localize.DataScience.restartKernelMessageDontAskAgain();
const no = localize.DataScience.restartKernelMessageNo();

const v = await this.applicationShell.showInformationMessage(message, yes, dontAskAgain, no);
if (v === dontAskAgain) {
await this.disableAskForRestart();
await this.restartKernelInternal();
} else if (v === yes) {
this.restartingKernel = true;
this.startProgress();

try {
if (await this.shouldAskForRestart()) {
// Ask the user if they want us to restart or not.
const message = localize.DataScience.restartKernelMessage();
const yes = localize.DataScience.restartKernelMessageYes();
const dontAskAgain = localize.DataScience.restartKernelMessageDontAskAgain();
const no = localize.DataScience.restartKernelMessageNo();

const v = await this.applicationShell.showInformationMessage(message, yes, dontAskAgain, no);
if (v === dontAskAgain) {
await this.disableAskForRestart();
await this.restartKernelInternal();
} else if (v === yes) {
await this.restartKernelInternal();
}
} else {
await this.restartKernelInternal();
}
} else {
await this.restartKernelInternal();
} finally {
this.restartingKernel = false;
this.stopProgress();
}
}
}

@captureTelemetry(Telemetry.Interrupt)
public async interruptKernel(): Promise<void> {
if (this._notebook && !this.restartingKernel) {
this.restartingKernel = true;
this.startProgress();

const status = this.statusProvider.set(
localize.DataScience.interruptKernelStatus(),
true,
Expand All @@ -412,10 +423,10 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp
this
);

const settings = this.configuration.getSettings(await this.getOwningResource());
const interruptTimeout = settings.datascience.jupyterInterruptTimeout;

try {
const settings = this.configuration.getSettings(await this.getOwningResource());
const interruptTimeout = settings.datascience.jupyterInterruptTimeout;

const result = await this._notebook.interruptKernel(interruptTimeout);
status.dispose();

Expand All @@ -436,6 +447,9 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp
status.dispose();
traceError(err);
this.applicationShell.showErrorMessage(err);
} finally {
this.restartingKernel = false;
this.stopProgress();
}
}
}
Expand Down
12 changes: 2 additions & 10 deletions src/datascience-ui/interactive-common/redux/reducers/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,13 @@ export namespace Kernel {
export function restartKernel(arg: CommonReducerArg): IMainState {
postActionToExtension(arg, InteractiveWindowMessages.RestartKernel);

// Set busy until kernel is restarted
return {
...arg.prevState,
busy: true
};
return arg.prevState;
}

export function interruptKernel(arg: CommonReducerArg): IMainState {
postActionToExtension(arg, InteractiveWindowMessages.Interrupt);

// Set busy until kernel is finished interrupting
return {
...arg.prevState,
busy: true
};
return arg.prevState;
}

export function updateStatus(
Expand Down