Skip to content

Commit bd9615a

Browse files
authored
Fix interrupts from always indicating restart (#10228)
1 parent 706cd92 commit bd9615a

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

news/2 Fixes/10050.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix interrupts from always thinking a restart occurred.

src/client/datascience/jupyter/jupyterNotebook.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,8 @@ export class JupyterNotebookBase implements INotebook {
463463
const restarted = createDeferred<CellState[]>();
464464

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

485485
// Start our interrupt. If it fails, indicate a restart
486-
this.session
487-
.interrupt(timeoutMs)
488-
.then(() => restarted.resolve([]))
489-
.catch(exc => {
490-
traceWarning(`Error during interrupt: ${exc}`);
491-
restarted.resolve([]);
492-
});
486+
this.session.interrupt(timeoutMs).catch(exc => {
487+
traceWarning(`Error during interrupt: ${exc}`);
488+
restarted.resolve([]);
489+
});
493490

494491
try {
495492
// Wait for all of the pending cells to finish or the timeout to fire

src/test/datascience/notebook.functional.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,8 @@ suite('DataScience notebook tests', () => {
984984
assert.equal(finishedBefore, false, 'Finished before the interruption');
985985
assert.equal(error, undefined, 'Error thrown during interrupt');
986986
assert.ok(
987-
finishedPromise.completed || result === InterruptResult.TimedOut || result === InterruptResult.Restarted,
988-
`Timed out before interrupt for result: ${result}: ${code}`
987+
finishedPromise.completed || result === InterruptResult.TimedOut || result === InterruptResult.Success,
988+
`Interrupt restarted ${result} for: ${code}`
989989
);
990990

991991
return result;

0 commit comments

Comments
 (0)