-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Use events.one
vs events.on
inside of CodeCell.execute
#2354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When does this fire? What happens when a new kernel is launched?
stop_on_error : stop_on_error}); | ||
CodeCell.msg_cells[this.last_msg_id] = this; | ||
this.render(); | ||
this.events.trigger('execute.CodeCell', {cell: this}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rgbkrk When a CodeCell is executed, 'execute.CodeCell'
is triggered, but apparently no event is triggered when execution completes.
var that = this; | ||
this.events.on('finished_iopub.Kernel', function (evt, data) { | ||
this.events.one('finished_iopub.Kernel', function (evt, data) { | ||
if (that.kernel.id === data.kernel.id && that.last_msg_id === data.msg_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When 'finished_iopub.Kernel'
is triggered and its data matches that of the CodeCell, then we know that execution is complete.
this.events.trigger('execute.CodeCell', {cell: this}); | ||
var that = this; | ||
this.events.on('finished_iopub.Kernel', function (evt, data) { | ||
this.events.one('finished_iopub.Kernel', function (evt, data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I just realized that if another cell's execution completes in between this cell's execution starting and completing, then this event listener will be disposed before it can handle execution completion...
Patches #2061
Closes #2352