##// END OF EJS Templates
allow callbacks on status messages
MinRK -
Show More
@@ -481,12 +481,22 var IPython = (function (IPython) {
481
481
482 Kernel.prototype._handle_status_message = function (msg) {
482 Kernel.prototype._handle_status_message = function (msg) {
483 var execution_state = msg.content.execution_state;
483 var execution_state = msg.content.execution_state;
484 var parent_id = msg.parent_header.msg_id;
485
486 // dispatch status msg callbacks, if any
487 var callbacks = this.get_callbacks_for_msg(parent_id);
488 if (callbacks && callbacks.iopub && callbacks.iopub.status) {
489 try {
490 callbacks.iopub.status(msg);
491 } catch (e) {
492 console.log("Exception in status msg handler", e);
493 }
494 }
495
484 if (execution_state === 'busy') {
496 if (execution_state === 'busy') {
485 $([IPython.events]).trigger('status_busy.Kernel', {kernel: this});
497 $([IPython.events]).trigger('status_busy.Kernel', {kernel: this});
486 } else if (execution_state === 'idle') {
498 } else if (execution_state === 'idle') {
487 // clear callbacks
499 // clear callbacks on idle, there can be no more
488 var parent_id = msg.parent_header.msg_id;
489 var callbacks = this.get_callbacks_for_msg(parent_id);
490 if (callbacks !== undefined) {
500 if (callbacks !== undefined) {
491 delete callbacks.iopub;
501 delete callbacks.iopub;
492 delete callbacks.input;
502 delete callbacks.input;
@@ -494,7 +504,7 var IPython = (function (IPython) {
494 this.clear_callbacks_for_msg(parent_id);
504 this.clear_callbacks_for_msg(parent_id);
495 }
505 }
496 }
506 }
497
507 // trigger status_idle event
498 $([IPython.events]).trigger('status_idle.Kernel', {kernel: this});
508 $([IPython.events]).trigger('status_idle.Kernel', {kernel: this});
499 } else if (execution_state === 'restarting') {
509 } else if (execution_state === 'restarting') {
500 // autorestarting is distinct from restarting,
510 // autorestarting is distinct from restarting,
General Comments 0
You need to be logged in to leave comments. Login now