##// END OF EJS Templates
Add docstrings to kernel.js
Jessica B. Hamrick -
Show More
@@ -10,10 +10,18 define([
10 ], function(IPython, $, utils, comm, widgetmanager) {
10 ], function(IPython, $, utils, comm, widgetmanager) {
11 "use strict";
11 "use strict";
12
12
13 // Initialization and connection.
14 /**
13 /**
15 * A Kernel Class to communicate with the Python kernel
14 * A Kernel class to communicate with the Python kernel. This
16 * @Class Kernel
15 * should generally not be constructed directly, but be created
16 * by. the `Session` object. Once created, this object should be
17 * used to communicate with the kernel.
18 *
19 * @class Kernel
20 * @param {string} kernel_service_url - the URL to access the kernel REST api
21 * @param {string} ws_url - the websockets URL
22 * @param {Notebook} notebook - notebook object
23 * @param {string} id - the kernel id
24 * @param {string} name - the kernel type (e.g. python3)
17 */
25 */
18 var Kernel = function (kernel_service_url, ws_url, notebook, id, name) {
26 var Kernel = function (kernel_service_url, ws_url, notebook, id, name) {
19 this.events = notebook.events;
27 this.events = notebook.events;
@@ -56,7 +64,9 define([
56 this.last_msg_callbacks = {};
64 this.last_msg_callbacks = {};
57 };
65 };
58
66
59
67 /**
68 * @function _get_msg
69 */
60 Kernel.prototype._get_msg = function (msg_type, content, metadata) {
70 Kernel.prototype._get_msg = function (msg_type, content, metadata) {
61 var msg = {
71 var msg = {
62 header : {
72 header : {
@@ -73,6 +83,9 define([
73 return msg;
83 return msg;
74 };
84 };
75
85
86 /**
87 * @function bind_events
88 */
76 Kernel.prototype.bind_events = function () {
89 Kernel.prototype.bind_events = function () {
77 var that = this;
90 var that = this;
78 this.events.on('send_input_reply.Kernel', function(evt, data) {
91 this.events.on('send_input_reply.Kernel', function(evt, data) {
@@ -80,8 +93,11 define([
80 });
93 });
81 };
94 };
82
95
83 // Initialize the iopub handlers
96 /**
84
97 * Initialize the iopub handlers.
98 *
99 * @function init_iopub_handlers
100 */
85 Kernel.prototype.init_iopub_handlers = function () {
101 Kernel.prototype.init_iopub_handlers = function () {
86 var output_msg_types = ['stream', 'display_data', 'execute_result', 'error'];
102 var output_msg_types = ['stream', 'display_data', 'execute_result', 'error'];
87 this._iopub_handlers = {};
103 this._iopub_handlers = {};
@@ -95,6 +111,12 define([
95
111
96 /**
112 /**
97 * GET /api/kernels
113 * GET /api/kernels
114 *
115 * Get the list of running kernels.
116 *
117 * @function list
118 * @param {function} [success] - function executed on ajax success
119 * @param {function} [error] - functon executed on ajax error
98 */
120 */
99 Kernel.prototype.list = function (success, error) {
121 Kernel.prototype.list = function (success, error) {
100 $.ajax(this.kernel_service_url, {
122 $.ajax(this.kernel_service_url, {
@@ -110,10 +132,17 define([
110 /**
132 /**
111 * POST /api/kernels
133 * POST /api/kernels
112 *
134 *
135 * Start a new kernel.
136 *
113 * In general this shouldn't be used -- the kernel should be
137 * In general this shouldn't be used -- the kernel should be
114 * started through the session API. If you use this function and
138 * started through the session API. If you use this function and
115 * are also using the session API then your session and kernel
139 * are also using the session API then your session and kernel
116 * WILL be out of sync!
140 * WILL be out of sync!
141 *
142 * @function start
143 * @param {params} [Object] - parameters to include in the query string
144 * @param {function} [success] - function executed on ajax success
145 * @param {function} [error] - functon executed on ajax error
117 */
146 */
118 Kernel.prototype.start = function (params, success, error) {
147 Kernel.prototype.start = function (params, success, error) {
119 var url = this.kernel_service_url;
148 var url = this.kernel_service_url;
@@ -126,7 +155,7 define([
126 var on_success = function (data, status, xhr) {
155 var on_success = function (data, status, xhr) {
127 that.id = data.id;
156 that.id = data.id;
128 that.kernel_url = utils.url_join_encode(that.kernel_service_url, that.id);
157 that.kernel_url = utils.url_join_encode(that.kernel_service_url, that.id);
129 that._kernel_started(data);
158 that._kernel_started();
130 if (success) {
159 if (success) {
131 success(data, status, xhr);
160 success(data, status, xhr);
132 }
161 }
@@ -147,6 +176,12 define([
147
176
148 /**
177 /**
149 * GET /api/kernels/[:kernel_id]
178 * GET /api/kernels/[:kernel_id]
179 *
180 * Get information about the kernel.
181 *
182 * @function get_info
183 * @param {function} [success] - function executed on ajax success
184 * @param {function} [error] - functon executed on ajax error
150 */
185 */
151 Kernel.prototype.get_info = function (success, error) {
186 Kernel.prototype.get_info = function (success, error) {
152 $.ajax(this.kernel_url, {
187 $.ajax(this.kernel_url, {
@@ -161,6 +196,16 define([
161
196
162 /**
197 /**
163 * DELETE /api/kernels/[:kernel_id]
198 * DELETE /api/kernels/[:kernel_id]
199 *
200 * Shutdown the kernel.
201 *
202 * If you are also using sessions, then this function shoul NOT be
203 * used. Instead, use Session.delete. Otherwise, the session and
204 * kernel WILL be out of sync.
205 *
206 * @function kill
207 * @param {function} [success] - function executed on ajax success
208 * @param {function} [error] - functon executed on ajax error
164 */
209 */
165 Kernel.prototype.kill = function (success, error) {
210 Kernel.prototype.kill = function (success, error) {
166 this._kernel_dead();
211 this._kernel_dead();
@@ -176,6 +221,12 define([
176
221
177 /**
222 /**
178 * POST /api/kernels/[:kernel_id]/interrupt
223 * POST /api/kernels/[:kernel_id]/interrupt
224 *
225 * Interrupt the kernel.
226 *
227 * @function interrupt
228 * @param {function} [success] - function executed on ajax success
229 * @param {function} [error] - functon executed on ajax error
179 */
230 */
180 Kernel.prototype.interrupt = function (success, error) {
231 Kernel.prototype.interrupt = function (success, error) {
181 this.events.trigger('status_interrupting.Kernel', {kernel: this});
232 this.events.trigger('status_interrupting.Kernel', {kernel: this});
@@ -192,6 +243,12 define([
192
243
193 /**
244 /**
194 * POST /api/kernels/[:kernel_id]/restart
245 * POST /api/kernels/[:kernel_id]/restart
246 *
247 * Restart the kernel.
248 *
249 * @function interrupt
250 * @param {function} [success] - function executed on ajax success
251 * @param {function} [error] - functon executed on ajax error
195 */
252 */
196 Kernel.prototype.restart = function (success, error) {
253 Kernel.prototype.restart = function (success, error) {
197 this.events.trigger('status_restarting.Kernel', {kernel: this});
254 this.events.trigger('status_restarting.Kernel', {kernel: this});
@@ -199,7 +256,7 define([
199
256
200 var that = this;
257 var that = this;
201 var on_success = function (data, status, xhr) {
258 var on_success = function (data, status, xhr) {
202 that._kernel_started(data, status, xhr);
259 that._kernel_started();
203 if (success) {
260 if (success) {
204 success(data, status, xhr);
261 success(data, status, xhr);
205 }
262 }
@@ -217,8 +274,11 define([
217 };
274 };
218
275
219 /**
276 /**
220 * Not actually a HTTP request, but useful function nonetheless
277 * Reconnect to a disconnected kernel. This is not actually a
221 * for reconnecting to the kernel if the connection is somehow lost
278 * standard HTTP request, but useful function nonetheless for
279 * reconnecting to the kernel if the connection is somehow lost.
280 *
281 * @function reconnect
222 */
282 */
223 Kernel.prototype.reconnect = function () {
283 Kernel.prototype.reconnect = function () {
224 this.events.trigger('status_reconnecting.Kernel');
284 this.events.trigger('status_reconnecting.Kernel');
@@ -228,6 +288,14 define([
228 }, 5000);
288 }, 5000);
229 };
289 };
230
290
291 /**
292 * Handle a successful AJAX request by updating the kernel id and
293 * name from the response, and then optionally calling a provided
294 * callback.
295 *
296 * @function _on_success
297 * @param {function} success - callback
298 */
231 Kernel.prototype._on_success = function (success) {
299 Kernel.prototype._on_success = function (success) {
232 var that = this;
300 var that = this;
233 return function (data, status, xhr) {
301 return function (data, status, xhr) {
@@ -242,6 +310,13 define([
242 };
310 };
243 };
311 };
244
312
313 /**
314 * Handle a failed AJAX request by logging the error message, and
315 * then optionally calling a provided callback.
316 *
317 * @function _on_error
318 * @param {function} error - callback
319 */
245 Kernel.prototype._on_error = function (error) {
320 Kernel.prototype._on_error = function (error) {
246 return function (xhr, status, err) {
321 return function (xhr, status, err) {
247 utils.log_ajax_error(xhr, status, err);
322 utils.log_ajax_error(xhr, status, err);
@@ -251,12 +326,27 define([
251 };
326 };
252 };
327 };
253
328
254 Kernel.prototype._kernel_started = function (json) {
329 /**
255 console.log("Kernel started: ", json.id);
330 * Perform necessary tasks once the kernel has been started. This
331 * includes triggering the 'status_started.Kernel' event and
332 * then actually connecting to the kernel.
333 *
334 * @function _kernel_started
335 */
336 Kernel.prototype._kernel_started = function () {
337 console.log("Kernel started: ", this.id);
256 this.events.trigger('status_started.Kernel', {kernel: this});
338 this.events.trigger('status_started.Kernel', {kernel: this});
257 this.start_channels();
339 this.start_channels();
258 };
340 };
259
341
342 /**
343 * Perform necessary tasks once the connection to the kernel has
344 * been established. This includes triggering the
345 * 'status_connected.Kernel' event and then requesting information
346 * about the kernel.
347 *
348 * @function _kernel_connected
349 */
260 Kernel.prototype._kernel_connected = function () {
350 Kernel.prototype._kernel_connected = function () {
261 var that = this;
351 var that = this;
262 console.log('Connected to kernel: ', this.id);
352 console.log('Connected to kernel: ', this.id);
@@ -266,18 +356,25 define([
266 });
356 });
267 };
357 };
268
358
359 /**
360 * Perform necessary tasks after the kernel has died. This
361 * includes triggering both 'status_dead.Kernel' and
362 * 'no_kernel.Kernel', and then closing communication channels to
363 * the kernel if they are still somehow open.
364 *
365 * @function _kernel_dead
366 */
269 Kernel.prototype._kernel_dead = function () {
367 Kernel.prototype._kernel_dead = function () {
270 this.events.trigger('status_dead.Kernel');
368 this.events.trigger('status_dead.Kernel');
271 this.events.trigger('no_kernel.Kernel');
369 this.events.trigger('no_kernel.Kernel');
272 this.stop_channels();
370 this.stop_channels();
273 };
371 };
274
372
275
276 /**
373 /**
277 * Start the `shell`and `iopub` channels.
374 * Start the `shell`and `iopub` channels.
278 * Will stop and restart them if they already exist.
375 * Will stop and restart them if they already exist.
279 *
376 *
280 * @method start_channels
377 * @function start_channels
281 */
378 */
282 Kernel.prototype.start_channels = function () {
379 Kernel.prototype.start_channels = function () {
283 var that = this;
380 var that = this;
@@ -340,10 +437,10 define([
340 };
437 };
341
438
342 /**
439 /**
343 * Handle a websocket entering the open state
440 * Handle a websocket entering the open state sends session and
344 * sends session and cookie authentication info as first message.
441 * cookie authentication info as first message.
345 * Once all sockets are open, signal the Kernel.status_started event.
442 *
346 * @method _ws_opened
443 * @function _ws_opened
347 */
444 */
348 Kernel.prototype._ws_opened = function (evt) {
445 Kernel.prototype._ws_opened = function (evt) {
349 // send the session id so the Session object Python-side
446 // send the session id so the Session object Python-side
@@ -356,6 +453,17 define([
356 }
453 }
357 };
454 };
358
455
456 /**
457 * Handle a websocket entering the closed state. This closes the
458 * other communication channels if they are open, and triggers the
459 * 'status_disconnected.Kernel' event. If the websocket was closed
460 * early, then also trigger 'early_disconnect.Kernel'. Otherwise,
461 * try to reconnect to the kernel.
462 *
463 * @function _ws_closed
464 * @param {string} ws_url - the websocket url
465 * @param {bool} early - whether the connection was closed early or not
466 */
359 Kernel.prototype._ws_closed = function(ws_url, early) {
467 Kernel.prototype._ws_closed = function(ws_url, early) {
360 this.stop_channels();
468 this.stop_channels();
361 this.events.trigger('status_disconnected.Kernel');
469 this.events.trigger('status_disconnected.Kernel');
@@ -368,8 +476,10 define([
368 };
476 };
369
477
370 /**
478 /**
371 * Stop the websocket channels.
479 * Close the websocket channels. After successful close, the value
372 * @method stop_channels
480 * in `this.channels[channel_name]` will be null.
481 *
482 * @function stop_channels
373 */
483 */
374 Kernel.prototype.stop_channels = function () {
484 Kernel.prototype.stop_channels = function () {
375 var that = this;
485 var that = this;
@@ -388,8 +498,14 define([
388 }
498 }
389 };
499 };
390
500
391 // Main public methods.
501 /**
392
502 * Check whether there is a connection to the kernel. This
503 * function only returns true if all channel objects have been
504 * created and have a state of WebSocket.OPEN.
505 *
506 * @function is_connected
507 * @returns {bool} - whether there is a connection
508 */
393 Kernel.prototype.is_connected = function () {
509 Kernel.prototype.is_connected = function () {
394 for (var c in this.channels) {
510 for (var c in this.channels) {
395 // if any channel is not ready, then we're not connected
511 // if any channel is not ready, then we're not connected
@@ -403,6 +519,14 define([
403 return true;
519 return true;
404 };
520 };
405
521
522 /**
523 * Check whether the connection to the kernel has been completely
524 * severed. This function only returns true if all channel objects
525 * are null.
526 *
527 * @function is_fully_disconnected
528 * @returns {bool} - whether the kernel is fully disconnected
529 */
406 Kernel.prototype.is_fully_disconnected = function () {
530 Kernel.prototype.is_fully_disconnected = function () {
407 for (var c in this.channels) {
531 for (var c in this.channels) {
408 if (this.channels[c] === null) {
532 if (this.channels[c] === null) {
@@ -412,7 +536,11 define([
412 return false;
536 return false;
413 };
537 };
414
538
415 // send a message on the Kernel's shell channel
539 /**
540 * Send a message on the Kernel's shell channel
541 *
542 * @function send_shell_message
543 */
416 Kernel.prototype.send_shell_message = function (msg_type, content, callbacks, metadata) {
544 Kernel.prototype.send_shell_message = function (msg_type, content, callbacks, metadata) {
417 if (!this.is_connected()) {
545 if (!this.is_connected()) {
418 throw new Error("kernel is not connected");
546 throw new Error("kernel is not connected");
@@ -426,8 +554,8 define([
426 /**
554 /**
427 * Get kernel info
555 * Get kernel info
428 *
556 *
557 * @function kernel_info
429 * @param callback {function}
558 * @param callback {function}
430 * @method kernel_info
431 *
559 *
432 * When calling this method, pass a callback function that expects one argument.
560 * When calling this method, pass a callback function that expects one argument.
433 * The callback will be passed the complete `kernel_info_reply` message documented
561 * The callback will be passed the complete `kernel_info_reply` message documented
@@ -444,14 +572,14 define([
444 /**
572 /**
445 * Get info on an object
573 * Get info on an object
446 *
574 *
447 * @param code {string}
448 * @param cursor_pos {integer}
449 * @param callback {function}
450 * @method inspect
451 *
452 * When calling this method, pass a callback function that expects one argument.
575 * When calling this method, pass a callback function that expects one argument.
453 * The callback will be passed the complete `inspect_reply` message documented
576 * The callback will be passed the complete `inspect_reply` message documented
454 * [here](http://ipython.org/ipython-doc/dev/development/messaging.html#object-information)
577 * [here](http://ipython.org/ipython-doc/dev/development/messaging.html#object-information)
578 *
579 * @function inspect
580 * @param code {string}
581 * @param cursor_pos {integer}
582 * @param callback {function}
455 */
583 */
456 Kernel.prototype.inspect = function (code, cursor_pos, callback) {
584 Kernel.prototype.inspect = function (code, cursor_pos, callback) {
457 var callbacks;
585 var callbacks;
@@ -471,7 +599,7 define([
471 * Execute given code into kernel, and pass result to callback.
599 * Execute given code into kernel, and pass result to callback.
472 *
600 *
473 * @async
601 * @async
474 * @method execute
602 * @function execute
475 * @param {string} code
603 * @param {string} code
476 * @param [callbacks] {Object} With the following keys (all optional)
604 * @param [callbacks] {Object} With the following keys (all optional)
477 * @param callbacks.shell.reply {function}
605 * @param callbacks.shell.reply {function}
@@ -486,8 +614,8 define([
486 *
614 *
487 * @example
615 * @example
488 *
616 *
489 * The options object should contain the options for the execute call. Its default
617 * The options object should contain the options for the execute
490 * values are:
618 * call. Its default values are:
491 *
619 *
492 * options = {
620 * options = {
493 * silent : true,
621 * silent : true,
@@ -495,7 +623,8 define([
495 * allow_stdin : false
623 * allow_stdin : false
496 * }
624 * }
497 *
625 *
498 * When calling this method pass a callbacks structure of the form:
626 * When calling this method pass a callbacks structure of the
627 * form:
499 *
628 *
500 * callbacks = {
629 * callbacks = {
501 * shell : {
630 * shell : {
@@ -511,8 +640,9 define([
511 * input : raw_input_callback
640 * input : raw_input_callback
512 * }
641 * }
513 *
642 *
514 * Each callback will be passed the entire message as a single arugment.
643 * Each callback will be passed the entire message as a single
515 * Payload handlers will be passed the corresponding payload and the execute_reply message.
644 * arugment. Payload handlers will be passed the corresponding
645 * payload and the execute_reply message.
516 */
646 */
517 Kernel.prototype.execute = function (code, callbacks, options) {
647 Kernel.prototype.execute = function (code, callbacks, options) {
518 var content = {
648 var content = {
@@ -532,17 +662,16 define([
532 };
662 };
533
663
534 /**
664 /**
535 * When calling this method, pass a function to be called with the `complete_reply` message
665 * When calling this method, pass a function to be called with the
536 * as its only argument when it arrives.
666 * `complete_reply` message as its only argument when it arrives.
537 *
667 *
538 * `complete_reply` is documented
668 * `complete_reply` is documented
539 * [here](http://ipython.org/ipython-doc/dev/development/messaging.html#complete)
669 * [here](http://ipython.org/ipython-doc/dev/development/messaging.html#complete)
540 *
670 *
541 * @method complete
671 * @function complete
542 * @param code {string}
672 * @param code {string}
543 * @param cursor_pos {integer}
673 * @param cursor_pos {integer}
544 * @param callback {function}
674 * @param callback {function}
545 *
546 */
675 */
547 Kernel.prototype.complete = function (code, cursor_pos, callback) {
676 Kernel.prototype.complete = function (code, cursor_pos, callback) {
548 var callbacks;
677 var callbacks;
@@ -556,6 +685,9 define([
556 return this.send_shell_message("complete_request", content, callbacks);
685 return this.send_shell_message("complete_request", content, callbacks);
557 };
686 };
558
687
688 /**
689 * @function send_input_reply
690 */
559 Kernel.prototype.send_input_reply = function (input) {
691 Kernel.prototype.send_input_reply = function (input) {
560 if (!this.is_connected()) {
692 if (!this.is_connected()) {
561 throw new Error("kernel is not connected");
693 throw new Error("kernel is not connected");
@@ -569,21 +701,28 define([
569 return msg.header.msg_id;
701 return msg.header.msg_id;
570 };
702 };
571
703
572
704 /**
573 // Reply handlers
705 * @function register_iopub_handler
574
706 */
575 Kernel.prototype.register_iopub_handler = function (msg_type, callback) {
707 Kernel.prototype.register_iopub_handler = function (msg_type, callback) {
576 this._iopub_handlers[msg_type] = callback;
708 this._iopub_handlers[msg_type] = callback;
577 };
709 };
578
710
711 /**
712 * Get the iopub handler for a specific message type.
713 *
714 * @function get_iopub_handler
715 */
579 Kernel.prototype.get_iopub_handler = function (msg_type) {
716 Kernel.prototype.get_iopub_handler = function (msg_type) {
580 // get iopub handler for a specific message type
581 return this._iopub_handlers[msg_type];
717 return this._iopub_handlers[msg_type];
582 };
718 };
583
719
584
720 /**
721 * Get callbacks for a specific message.
722 *
723 * @function get_callbacks_for_msg
724 */
585 Kernel.prototype.get_callbacks_for_msg = function (msg_id) {
725 Kernel.prototype.get_callbacks_for_msg = function (msg_id) {
586 // get callbacks for a specific message
587 if (msg_id == this.last_msg_id) {
726 if (msg_id == this.last_msg_id) {
588 return this.last_msg_callbacks;
727 return this.last_msg_callbacks;
589 } else {
728 } else {
@@ -591,13 +730,20 define([
591 }
730 }
592 };
731 };
593
732
594
733 /**
734 * Clear callbacks for a specific message.
735 *
736 * @function clear_callbacks_for_msg
737 */
595 Kernel.prototype.clear_callbacks_for_msg = function (msg_id) {
738 Kernel.prototype.clear_callbacks_for_msg = function (msg_id) {
596 if (this._msg_callbacks[msg_id] !== undefined ) {
739 if (this._msg_callbacks[msg_id] !== undefined ) {
597 delete this._msg_callbacks[msg_id];
740 delete this._msg_callbacks[msg_id];
598 }
741 }
599 };
742 };
600
743
744 /**
745 * @function _finish_shell
746 */
601 Kernel.prototype._finish_shell = function (msg_id) {
747 Kernel.prototype._finish_shell = function (msg_id) {
602 var callbacks = this._msg_callbacks[msg_id];
748 var callbacks = this._msg_callbacks[msg_id];
603 if (callbacks !== undefined) {
749 if (callbacks !== undefined) {
@@ -608,6 +754,9 define([
608 }
754 }
609 };
755 };
610
756
757 /**
758 * @function _finish_iopub
759 */
611 Kernel.prototype._finish_iopub = function (msg_id) {
760 Kernel.prototype._finish_iopub = function (msg_id) {
612 var callbacks = this._msg_callbacks[msg_id];
761 var callbacks = this._msg_callbacks[msg_id];
613 if (callbacks !== undefined) {
762 if (callbacks !== undefined) {
@@ -618,12 +767,14 define([
618 }
767 }
619 };
768 };
620
769
621 /* Set callbacks for a particular message.
770 /**
771 * Set callbacks for a particular message.
622 * Callbacks should be a struct of the following form:
772 * Callbacks should be a struct of the following form:
623 * shell : {
773 * shell : {
624 *
774 *
625 * }
775 * }
626
776 *
777 * @function set_callbacks_for_msg
627 */
778 */
628 Kernel.prototype.set_callbacks_for_msg = function (msg_id, callbacks) {
779 Kernel.prototype.set_callbacks_for_msg = function (msg_id, callbacks) {
629 this.last_msg_id = msg_id;
780 this.last_msg_id = msg_id;
@@ -640,7 +791,9 define([
640 }
791 }
641 };
792 };
642
793
643
794 /**
795 * @function _handle_shell_reply
796 */
644 Kernel.prototype._handle_shell_reply = function (e) {
797 Kernel.prototype._handle_shell_reply = function (e) {
645 var reply = $.parseJSON(e.data);
798 var reply = $.parseJSON(e.data);
646 this.events.trigger('shell_reply.Kernel', {kernel: this, reply:reply});
799 this.events.trigger('shell_reply.Kernel', {kernel: this, reply:reply});
@@ -664,7 +817,9 define([
664 }
817 }
665 };
818 };
666
819
667
820 /**
821 * @function _handle_payloads
822 */
668 Kernel.prototype._handle_payloads = function (payloads, payload_callbacks, msg) {
823 Kernel.prototype._handle_payloads = function (payloads, payload_callbacks, msg) {
669 var l = payloads.length;
824 var l = payloads.length;
670 // Payloads are handled by triggering events because we don't want the Kernel
825 // Payloads are handled by triggering events because we don't want the Kernel
@@ -678,6 +833,9 define([
678 }
833 }
679 };
834 };
680
835
836 /**
837 * @function _handle_status_message
838 */
681 Kernel.prototype._handle_status_message = function (msg) {
839 Kernel.prototype._handle_status_message = function (msg) {
682 var execution_state = msg.content.execution_state;
840 var execution_state = msg.content.execution_state;
683 var parent_id = msg.parent_header.msg_id;
841 var parent_id = msg.parent_header.msg_id;
@@ -717,8 +875,11 define([
717 }
875 }
718 };
876 };
719
877
720
878 /**
721 // handle clear_output message
879 * Handle clear_output message
880 *
881 * @function _handle_clear_output
882 */
722 Kernel.prototype._handle_clear_output = function (msg) {
883 Kernel.prototype._handle_clear_output = function (msg) {
723 var callbacks = this.get_callbacks_for_msg(msg.parent_header.msg_id);
884 var callbacks = this.get_callbacks_for_msg(msg.parent_header.msg_id);
724 if (!callbacks || !callbacks.iopub) {
885 if (!callbacks || !callbacks.iopub) {
@@ -730,8 +891,11 define([
730 }
891 }
731 };
892 };
732
893
733
894 /**
734 // handle an output message (execute_result, display_data, etc.)
895 * handle an output message (execute_result, display_data, etc.)
896 *
897 * @function _handle_output_message
898 */
735 Kernel.prototype._handle_output_message = function (msg) {
899 Kernel.prototype._handle_output_message = function (msg) {
736 var callbacks = this.get_callbacks_for_msg(msg.parent_header.msg_id);
900 var callbacks = this.get_callbacks_for_msg(msg.parent_header.msg_id);
737 if (!callbacks || !callbacks.iopub) {
901 if (!callbacks || !callbacks.iopub) {
@@ -743,8 +907,12 define([
743 }
907 }
744 };
908 };
745
909
746 // dispatch IOPub messages to respective handlers.
910 /**
747 // each message type should have a handler.
911 * Dispatch IOPub messages to respective handlers. Each message
912 * type should have a handler.
913 *
914 * @function _handle_iopub_message
915 */
748 Kernel.prototype._handle_iopub_message = function (e) {
916 Kernel.prototype._handle_iopub_message = function (e) {
749 var msg = $.parseJSON(e.data);
917 var msg = $.parseJSON(e.data);
750
918
@@ -754,7 +922,9 define([
754 }
922 }
755 };
923 };
756
924
757
925 /**
926 * @function _handle_input_request
927 */
758 Kernel.prototype._handle_input_request = function (e) {
928 Kernel.prototype._handle_input_request = function (e) {
759 var request = $.parseJSON(e.data);
929 var request = $.parseJSON(e.data);
760 var header = request.header;
930 var header = request.header;
@@ -88,7 +88,7 define([
88 that.kernel = new kernel.Kernel(
88 that.kernel = new kernel.Kernel(
89 kernel_service_url, that.ws_url, that.notebook,
89 kernel_service_url, that.ws_url, that.notebook,
90 that.kernel_model.id, that.kernel_model.name);
90 that.kernel_model.id, that.kernel_model.name);
91 that.kernel._kernel_started(data.kernel);
91 that.kernel._kernel_started();
92 if (success) {
92 if (success) {
93 success(data, status, xhr);
93 success(data, status, xhr);
94 }
94 }
General Comments 0
You need to be logged in to leave comments. Login now