##// END OF EJS Templates
Merge pull request #4079 from minrk/status_started...
Matthias Bussonnier -
r12512:691db143 merge
parent child Browse files
Show More
@@ -119,7 +119,6 b' var IPython = (function (IPython) {'
119 119 this.ws_url = ws_url;
120 120 this.kernel_url = this.base_url + "/" + this.kernel_id;
121 121 this.start_channels();
122 $([IPython.events]).trigger('status_started.Kernel', {kernel: this});
123 122 };
124 123
125 124
@@ -144,11 +143,7 b' var IPython = (function (IPython) {'
144 143 this.shell_channel = new this.WebSocket(ws_url + "/shell");
145 144 this.stdin_channel = new this.WebSocket(ws_url + "/stdin");
146 145 this.iopub_channel = new this.WebSocket(ws_url + "/iopub");
147 send_cookie = function(){
148 // send the session id so the Session object Python-side
149 // has the same identity
150 this.send(that.session_id + ':' + document.cookie);
151 };
146
152 147 var already_called_onclose = false; // only alert once
153 148 var ws_closed_early = function(evt){
154 149 if (already_called_onclose){
@@ -170,7 +165,7 b' var IPython = (function (IPython) {'
170 165 };
171 166 var channels = [this.shell_channel, this.iopub_channel, this.stdin_channel];
172 167 for (var i=0; i < channels.length; i++) {
173 channels[i].onopen = send_cookie;
168 channels[i].onopen = $.proxy(this._ws_opened, this);
174 169 channels[i].onclose = ws_closed_early;
175 170 }
176 171 // switch from early-close to late-close message after 1s
@@ -187,7 +182,27 b' var IPython = (function (IPython) {'
187 182 };
188 183
189 184 /**
190 * Stop the `shell`and `iopub` channels.
185 * Handle a websocket entering the open state
186 * sends session and cookie authentication info as first message.
187 * Once all sockets are open, signal the Kernel.status_started event.
188 * @method _ws_opened
189 */
190 Kernel.prototype._ws_opened = function (evt) {
191 // send the session id so the Session object Python-side
192 // has the same identity
193 evt.target.send(this.session_id + ':' + document.cookie);
194
195 var channels = [this.shell_channel, this.iopub_channel, this.stdin_channel];
196 for (var i=0; i < channels.length; i++) {
197 // if any channel is not ready, don't trigger event.
198 if ( !channels[i].readyState ) return;
199 }
200 // all events ready, trigger started event.
201 $([IPython.events]).trigger('status_started.Kernel', {kernel: this});
202 };
203
204 /**
205 * Stop the websocket channels.
191 206 * @method stop_channels
192 207 */
193 208 Kernel.prototype.stop_channels = function () {
General Comments 0
You need to be logged in to leave comments. Login now