restart channels on kernel restart

generally not necessary, but sometimes the kernel connection can be dirty.
We have only seen this by starting a qtconsole via %qtconsole,
then killing the kernel, at which point the original notebook's connection
(at the zmq level) is never restored to the new kernel at the same endpoint.
It's weird, and probably a zmq bug, but a simple reconnect seems to solve it.
MinRK 13 years ago
parent 05ead0496b
commit e854617caf

@ -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();

Loading…
Cancel
Save