diff --git a/IPython/frontend/html/notebook/static/js/kernel.js b/IPython/frontend/html/notebook/static/js/kernel.js index 34c4b70..5b92f9e 100644 --- a/IPython/frontend/html/notebook/static/js/kernel.js +++ b/IPython/frontend/html/notebook/static/js/kernel.js @@ -104,8 +104,6 @@ var IPython = (function (IPython) { this.ws_url = json.ws_url; this.kernel_url = this.base_url + "/" + this.kernel_id; this.start_channels(); - this.shell_channel.onmessage = $.proxy(this._handle_shell_reply,this); - this.iopub_channel.onmessage = $.proxy(this._handle_iopub_reply,this); $([IPython.events]).trigger('status_started.Kernel', {kernel: this}); }; @@ -165,6 +163,8 @@ var IPython = (function (IPython) { that.iopub_channel.onclose = ws_closed_late; } }, 1000); + this.shell_channel.onmessage = $.proxy(this._handle_shell_reply,this); + this.iopub_channel.onmessage = $.proxy(this._handle_iopub_reply,this); }; /** @@ -419,6 +419,9 @@ var IPython = (function (IPython) { } else if (content.execution_state === 'idle') { $([IPython.events]).trigger('status_idle.Kernel', {kernel: this}); } else if (content.execution_state === 'restarting') { + // restart channels if kernel restarts + // avoids unlikely corrupted connection + setTimeout($.proxy(this.start_channels, this), 500); $([IPython.events]).trigger('status_restarting.Kernel', {kernel: this}); } else if (content.execution_state === 'dead') { this.stop_channels();