Skip to content

Fix interrupts from always indicating restart #10228

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
Feb 20, 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/10050.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix interrupts from always thinking a restart occurred.
15 changes: 6 additions & 9 deletions src/client/datascience/jupyter/jupyterNotebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ export class JupyterNotebookBase implements INotebook {
const restarted = createDeferred<CellState[]>();

// Listen to status change events so we can tell if we're restarting
const restartHandler = () => {
if (status === ServerStatus.Restarting) {
const restartHandler = (e: ServerStatus) => {
if (e === ServerStatus.Restarting) {
// We restarted the kernel.
this.sessionStartTime = Date.now();
traceWarning('Kernel restarting during interrupt');
Expand All @@ -483,13 +483,10 @@ export class JupyterNotebookBase implements INotebook {
const restartHandlerToken = this.session.onSessionStatusChanged(restartHandler);

// Start our interrupt. If it fails, indicate a restart
this.session
.interrupt(timeoutMs)
.then(() => restarted.resolve([]))
.catch(exc => {
traceWarning(`Error during interrupt: ${exc}`);
restarted.resolve([]);
});
this.session.interrupt(timeoutMs).catch(exc => {
traceWarning(`Error during interrupt: ${exc}`);
restarted.resolve([]);
});

try {
// Wait for all of the pending cells to finish or the timeout to fire
Expand Down
4 changes: 2 additions & 2 deletions src/test/datascience/notebook.functional.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,8 @@ suite('DataScience notebook tests', () => {
assert.equal(finishedBefore, false, 'Finished before the interruption');
assert.equal(error, undefined, 'Error thrown during interrupt');
assert.ok(
finishedPromise.completed || result === InterruptResult.TimedOut || result === InterruptResult.Restarted,
`Timed out before interrupt for result: ${result}: ${code}`
finishedPromise.completed || result === InterruptResult.TimedOut || result === InterruptResult.Success,
`Interrupt restarted ${result} for: ${code}`
);

return result;
Expand Down