|
40 | 40 |
|
41 | 41 | CONTROL_PRIORITY = 1 |
42 | 42 | SHELL_PRIORITY = 10 |
43 | | -ABORT_PRIORITY = 20 |
44 | 43 |
|
45 | 44 |
|
46 | 45 | class Kernel(SingletonConfigurable): |
@@ -182,10 +181,6 @@ def dispatch_control(self, msg): |
182 | 181 | # Set the parent message for side effects. |
183 | 182 | self.set_parent(idents, msg) |
184 | 183 | self._publish_status('busy') |
185 | | - if self._aborting: |
186 | | - self._send_abort_reply(self.control_stream, msg, idents) |
187 | | - self._publish_status('idle') |
188 | | - return |
189 | 184 |
|
190 | 185 | header = msg['header'] |
191 | 186 | msg_type = header['msg_type'] |
@@ -233,16 +228,17 @@ def dispatch_shell(self, stream, msg): |
233 | 228 | self.set_parent(idents, msg) |
234 | 229 | self._publish_status('busy') |
235 | 230 |
|
236 | | - if self._aborting: |
| 231 | + msg_type = msg['header']['msg_type'] |
| 232 | + |
| 233 | + # Only abort execute requests |
| 234 | + if self._aborting and msg_type == 'execute_request': |
237 | 235 | self._send_abort_reply(stream, msg, idents) |
238 | 236 | self._publish_status('idle') |
239 | 237 | # flush to ensure reply is sent before |
240 | 238 | # handling the next request |
241 | 239 | stream.flush(zmq.POLLOUT) |
242 | 240 | return |
243 | 241 |
|
244 | | - msg_type = msg['header']['msg_type'] |
245 | | - |
246 | 242 | # Print some info about this message and leave a '--->' marker, so it's |
247 | 243 | # easier to trace visually the message chain when debugging. Each |
248 | 244 | # handler prints its message at the end. |
@@ -792,16 +788,11 @@ def _abort_queues(self): |
792 | 788 | stream.flush() |
793 | 789 | self._aborting = True |
794 | 790 |
|
795 | | - self.schedule_dispatch( |
796 | | - ABORT_PRIORITY, |
797 | | - self._dispatch_abort, |
798 | | - ) |
| 791 | + def stop_aborting(f): |
| 792 | + self.log.info("Finishing abort") |
| 793 | + self._aborting = False |
799 | 794 |
|
800 | | - @gen.coroutine |
801 | | - def _dispatch_abort(self): |
802 | | - self.log.info("Finishing abort") |
803 | | - yield gen.sleep(self.stop_on_error_timeout) |
804 | | - self._aborting = False |
| 795 | + self.io_loop.add_future(gen.sleep(self.stop_on_error_timeout), stop_aborting) |
805 | 796 |
|
806 | 797 | def _send_abort_reply(self, stream, msg, idents): |
807 | 798 | """Send a reply to an aborted request""" |
|
0 commit comments