Skip to content

Commit

Permalink
Merge pull request #222 from flying-sheep/patch-1
Browse files Browse the repository at this point in the history
Ask for confirmation if kernel is busy

closes ipython/ipython#8546
  • Loading branch information
minrk committed Jul 23, 2015
2 parents ca2a539 + 3029212 commit 854aa1a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion notebook/static/notebook/js/notebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ define(function (require) {
this.next_prompt_number = 1;
this.session = null;
this.kernel = null;
this.kernel_busy = false;
this.clipboard = null;
this.undelete_backup = null;
this.undelete_index = null;
Expand Down Expand Up @@ -249,6 +250,14 @@ define(function (require) {
var cm_mode = langinfo.codemirror_mode || langinfo.name || 'null';
that.set_codemirror_mode(cm_mode);
});

this.events.on('kernel_idle.Kernel', function () {
that.kernel_busy = false;
});

this.events.on('kernel_busy.Kernel', function () {
that.kernel_busy = true;
});

var collapse_time = function (time) {
var app_height = $('#ipython-main-app').height(); // content height
Expand All @@ -274,7 +283,7 @@ define(function (require) {
var time = (extrap !== undefined) ? ((extrap.duration !== undefined ) ? extrap.duration : 'fast') : 'fast';
expand_time(time);
});

// Firefox 22 broke $(window).on("beforeunload")
// I'm not sure why or how.
window.onbeforeunload = function (e) {
Expand All @@ -301,6 +310,10 @@ define(function (require) {
return "Unsaved changes will be lost.";
}
}
// if the kernel is busy, prompt the user if he’s sure
if (that.kernel_busy) {
return "The Kernel is busy, outputs may be lost.";
}
// IE treats null as a string. Instead just return which will avoid the dialog.
return;
};
Expand Down

0 comments on commit 854aa1a

Please sign in to comment.