From a641041c6b1dc926081b252cfd2a56fa6e5a17b7 2014-10-08 18:30:29 From: Jessica B. Hamrick Date: 2014-10-08 18:30:29 Subject: [PATCH] Only set channels to null when they are fully closed --- diff --git a/IPython/html/static/services/kernels/js/kernel.js b/IPython/html/static/services/kernels/js/kernel.js index 76bc9fa..2ae0fcb 100644 --- a/IPython/html/static/services/kernels/js/kernel.js +++ b/IPython/html/static/services/kernels/js/kernel.js @@ -355,11 +355,18 @@ define([ * @method stop_channels */ Kernel.prototype.stop_channels = function () { + var that = this; + var close = function (c) { + return function () { + if (that.channels[c].readyState === WebSocket.CLOSED) { + that.channels[c] = null; + } + }; + }; for (var c in this.channels) { if ( this.channels[c] !== null ) { - this.channels[c].onclose = null; + this.channels[c].onclose = close(c); this.channels[c].close(); - this.channels[c] = null; } } }; @@ -378,6 +385,15 @@ define([ } return true; }; + + Kernel.prototype.is_fully_disconnected = function () { + for (var c in this.channels) { + if (this.channels[c] === null) { + return true; + } + } + return false; + }; // send a message on the Kernel's shell channel Kernel.prototype.send_shell_message = function (msg_type, content, callbacks, metadata) {