##// END OF EJS Templates
Using beforeunload to save at exit and kill the kernel.
Brian E. Granger -
Show More
@@ -63,7 +63,7 b' class KernelHandler(web.RequestHandler):'
63
63
64 def delete(self, kernel_id):
64 def delete(self, kernel_id):
65 rkm = self.application.routing_kernel_manager
65 rkm = self.application.routing_kernel_manager
66 self.kill_kernel(kernel_id)
66 rkm.kill_kernel(kernel_id)
67 self.set_status(204)
67 self.set_status(204)
68 self.finish()
68 self.finish()
69
69
@@ -80,10 +80,20 b' span.section_row_buttons > button {'
80 float: right;
80 float: right;
81 }
81 }
82
82
83 #kernel_persist {
84 float: right;
85 }
86
87 .checkbox_label {
88 font-size: 85%;
89 float: right;
90 padding: 0.3em;
91 }
92
83 .section_row_header {
93 .section_row_header {
84 float: left;
94 float: left;
85 font-size: 85%;
95 font-size: 85%;
86 padding: 0.2em 0em;
96 padding: 0.4em 0em;
87 font-weight: bold;
97 font-weight: bold;
88 }
98 }
89
99
@@ -87,7 +87,7 b' var IPython = (function (IPython) {'
87
87
88 Kernel.prototype.restart = function () {
88 Kernel.prototype.restart = function () {
89 IPython.kernel_status_widget.status_restarting();
89 IPython.kernel_status_widget.status_restarting();
90 url = this.kernel_url + "/restart"
90 var url = this.kernel_url + "/restart"
91 var that = this;
91 var that = this;
92 $.post(url, function (kernel_id) {
92 $.post(url, function (kernel_id) {
93 console.log("Kernel restarted: " + kernel_id);
93 console.log("Kernel restarted: " + kernel_id);
@@ -98,6 +98,14 b' var IPython = (function (IPython) {'
98 };
98 };
99
99
100
100
101 Kernel.prototype.kill = function () {
102 var settings = {
103 cache : false,
104 type : "DELETE",
105 };
106 $.ajax(this.kernel_url, settings);
107 };
108
101 IPython.Kernel = Kernel;
109 IPython.Kernel = Kernel;
102
110
103 return IPython;
111 return IPython;
@@ -32,6 +32,17 b' var IPython = (function (IPython) {'
32 this.element.find('button#save_notebook').click(function () {
32 this.element.find('button#save_notebook').click(function () {
33 IPython.notebook.save_notebook();
33 IPython.notebook.save_notebook();
34 });
34 });
35
36 $(window).bind('beforeunload', function () {
37 var kill_kernel = $('#kill_kernel').prop('checked');
38 IPython.notebook.save_notebook();
39 if (kill_kernel) {
40 IPython.notebook.kernel.kill();
41 return "You are about to exit this notebook and kill the kernel.";
42 } else {
43 return "You are about the exit this notebook and leave the kernel running.";
44 };
45 });
35 };
46 };
36
47
37
48
@@ -127,6 +127,12 b''
127 </span>
127 </span>
128 <span class="section_row_header">Actions</span>
128 <span class="section_row_header">Actions</span>
129 </div>
129 </div>
130 <div class="section_row">
131 <span id="kernel_persist">
132 <input type="checkbox" id="kill_kernel"></input>
133 </span>
134 <span class="checkbox_label">Kill kernel upon exit:</span>
135 </div>
130 </div>
136 </div>
131 </div>
137 </div>
132
138
General Comments 0
You need to be logged in to leave comments. Login now