Skip to content

Commit 8081f57

Browse files
Force comm reconnect when comm is closed (e.g. kernel restarts, etc)
1 parent b5c2c30 commit 8081f57

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

webio_jupyter_extension/webio-jupyter-labextension/labextension.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,17 @@ class WebIONotebookManager {
232232
) {
233233
// Stop attempting to handle callbacks if previous kernel is gone
234234
this._webIO.setSendCallback((msg: any) => {});
235+
236+
// Close comm to force a re-connect to the new/restarted kernel
237+
this.comm!.close();
235238
}
236239
},
237240
this,
238241
);
242+
this.comm.onClose = (msg: any) => {
243+
// Undefine comm so that the next connect call creates a new comm
244+
this.comm = undefined;
245+
};
239246

240247
this.setWebIOMetadata(kernel.id, this.comm.commId);
241248
}

0 commit comments

Comments
 (0)