Show More
@@ -110,36 +110,11 var IPython = (function (IPython) { | |||
|
110 | 110 | }; |
|
111 | 111 | |
|
112 | 112 | |
|
113 | Kernel.prototype._websocket_closed = function(ws_url, early){ | |
|
114 | var msg; | |
|
115 | var parent_item = $('body'); | |
|
116 | if (early) { | |
|
117 | msg = "Websocket connection to " + ws_url + " could not be established." + | |
|
118 | " You will NOT be able to run code." + | |
|
119 | " Your browser may not be compatible with the websocket version in the server," + | |
|
120 | " or if the url does not look right, there could be an error in the" + | |
|
121 | " server's configuration."; | |
|
122 | } else { | |
|
123 | IPython.notification_area.widget('kernel').set_message('Reconnecting Websockets', 1000); | |
|
124 | this.start_channels(); | |
|
125 | return; | |
|
126 | } | |
|
127 | var dialog = $('<div/>'); | |
|
128 | dialog.html(msg); | |
|
129 | parent_item.append(dialog); | |
|
130 | dialog.dialog({ | |
|
131 | resizable: false, | |
|
132 | modal: true, | |
|
133 | title: "Websocket closed", | |
|
134 | closeText: "", | |
|
135 | close: function(event, ui) {$(this).dialog('destroy').remove();}, | |
|
136 | buttons : { | |
|
137 | "OK": function () { | |
|
138 | $(this).dialog('close'); | |
|
139 | } | |
|
140 | } | |
|
141 | }); | |
|
142 | ||
|
113 | Kernel.prototype._websocket_closed = function(ws_url, early) { | |
|
114 | this.stop_channels(); | |
|
115 | $([IPython.events]).trigger('websocket_closed.Kernel', | |
|
116 | {ws_url: ws_url, kernel: this, early: early} | |
|
117 | ); | |
|
143 | 118 | }; |
|
144 | 119 | |
|
145 | 120 | /** |
@@ -152,7 +127,7 var IPython = (function (IPython) { | |||
|
152 | 127 | var that = this; |
|
153 | 128 | this.stop_channels(); |
|
154 | 129 | var ws_url = this.ws_url + this.kernel_url; |
|
155 | console.log("Starting WS:", ws_url); | |
|
130 | console.log("Starting WebSockets:", ws_url); | |
|
156 | 131 | this.shell_channel = new this.WebSocket(ws_url + "/shell"); |
|
157 | 132 | this.iopub_channel = new this.WebSocket(ws_url + "/iopub"); |
|
158 | 133 | send_cookie = function(){ |
@@ -182,9 +157,13 var IPython = (function (IPython) { | |||
|
182 | 157 | this.iopub_channel.onopen = send_cookie; |
|
183 | 158 | this.iopub_channel.onclose = ws_closed_early; |
|
184 | 159 | // switch from early-close to late-close message after 1s |
|
185 | setTimeout(function(){ | |
|
186 |
that.shell_channel |
|
|
187 |
that. |
|
|
160 | setTimeout(function() { | |
|
161 | if (that.shell_channel !== null) { | |
|
162 | that.shell_channel.onclose = ws_closed_late; | |
|
163 | } | |
|
164 | if (that.iopub_channel !== null) { | |
|
165 | that.iopub_channel.onclose = ws_closed_late; | |
|
166 | } | |
|
188 | 167 | }, 1000); |
|
189 | 168 | }; |
|
190 | 169 |
@@ -93,25 +93,72 var IPython = (function (IPython) { | |||
|
93 | 93 | |
|
94 | 94 | $([IPython.events]).on('status_dead.Kernel',function () { |
|
95 | 95 | var dialog = $('<div/>'); |
|
96 | dialog.html('The kernel has died, would you like to restart it? If you do not restart the kernel, you will be able to save the notebook, but running code will not work until the notebook is reopened.'); | |
|
96 | dialog.html('The kernel has died, would you like to restart it?' + | |
|
97 | ' If you do not restart the kernel, you will be able to save' + | |
|
98 | ' the notebook, but running code will not work until the notebook' + | |
|
99 | ' is reopened.' | |
|
100 | ); | |
|
97 | 101 | $(document).append(dialog); |
|
98 | 102 | dialog.dialog({ |
|
99 | 103 | resizable: false, |
|
100 | 104 | modal: true, |
|
101 | 105 | title: "Dead kernel", |
|
106 | close: function(event, ui) {$(this).dialog('destroy').remove();}, | |
|
102 | 107 | buttons : { |
|
103 | 108 | "Restart": function () { |
|
104 | 109 | $([IPython.events]).trigger('status_restarting.Kernel'); |
|
105 | 110 | IPython.notebook.start_kernel(); |
|
106 | 111 | $(this).dialog('close'); |
|
107 | 112 | }, |
|
108 |
" |
|
|
113 | "Don't restart": function () { | |
|
109 | 114 | $(this).dialog('close'); |
|
110 | 115 | } |
|
111 | 116 | } |
|
112 | 117 | }); |
|
113 | 118 | }); |
|
114 | 119 | |
|
120 | $([IPython.events]).on('websocket_closed.Kernel', function (event, data) { | |
|
121 | var kernel = data.kernel; | |
|
122 | var ws_url = data.ws_url; | |
|
123 | var early = data.early; | |
|
124 | var msg; | |
|
125 | console.log(early); | |
|
126 | if (!early) { | |
|
127 | knw.set_message('Reconnecting WebSockets', 1000); | |
|
128 | setTimeout(function () { | |
|
129 | kernel.start_channels(); | |
|
130 | }, 5000); | |
|
131 | return; | |
|
132 | } | |
|
133 | console.log('WebSocket connection failed: ', ws_url) | |
|
134 | msg = "A WebSocket connection to could not be established." + | |
|
135 | " You will NOT be able to run code. Check your" + | |
|
136 | " network connection or notebook server configuration."; | |
|
137 | var dialog = $('<div/>'); | |
|
138 | dialog.html(msg); | |
|
139 | $(document).append(dialog); | |
|
140 | dialog.dialog({ | |
|
141 | resizable: false, | |
|
142 | modal: true, | |
|
143 | title: "WebSocket connection failed", | |
|
144 | closeText: "", | |
|
145 | close: function(event, ui) {$(this).dialog('destroy').remove();}, | |
|
146 | buttons : { | |
|
147 | "OK": function () { | |
|
148 | $(this).dialog('close'); | |
|
149 | }, | |
|
150 | "Reconnect": function () { | |
|
151 | knw.set_message('Reconnecting WebSockets', 1000); | |
|
152 | setTimeout(function () { | |
|
153 | kernel.start_channels(); | |
|
154 | }, 5000); | |
|
155 | $(this).dialog('close'); | |
|
156 | } | |
|
157 | } | |
|
158 | }); | |
|
159 | }); | |
|
160 | ||
|
161 | ||
|
115 | 162 | var nnw = this.new_notification_widget('notebook'); |
|
116 | 163 | |
|
117 | 164 | // Notebook events |
General Comments 0
You need to be logged in to leave comments.
Login now