Show More
@@ -330,7 +330,7 b' class Kernel(Configurable):' | |||
|
330 | 330 | |
|
331 | 331 | def shutdown_request(self, ident, parent): |
|
332 | 332 | self.shell.exit_now = True |
|
333 |
self._shutdown_message = self.session.msg(u'shutdown_reply', |
|
|
333 | self._shutdown_message = self.session.msg(u'shutdown_reply', parent['content'], parent) | |
|
334 | 334 | sys.exit(0) |
|
335 | 335 | |
|
336 | 336 | #--------------------------------------------------------------------------- |
@@ -428,6 +428,7 b' class Kernel(Configurable):' | |||
|
428 | 428 | # io.rprint("Kernel at_shutdown") # dbg |
|
429 | 429 | if self._shutdown_message is not None: |
|
430 | 430 | self.reply_socket.send_json(self._shutdown_message) |
|
431 | self.pub_socket.send_json(self._shutdown_message) | |
|
431 | 432 | io.raw_print(self._shutdown_message) |
|
432 | 433 | # A very short sleep to give zmq time to flush its message buffers |
|
433 | 434 | # before Python truly shuts down. |
@@ -305,7 +305,7 b' class XReqSocketChannel(ZmqSocketChannel):' | |||
|
305 | 305 | self._queue_request(msg) |
|
306 | 306 | return msg['header']['msg_id'] |
|
307 | 307 | |
|
308 | def shutdown(self): | |
|
308 | def shutdown(self, restart=False): | |
|
309 | 309 | """Request an immediate kernel shutdown. |
|
310 | 310 | |
|
311 | 311 | Upon receipt of the (empty) reply, client code can safely assume that |
@@ -318,7 +318,7 b' class XReqSocketChannel(ZmqSocketChannel):' | |||
|
318 | 318 | """ |
|
319 | 319 | # Send quit message to kernel. Once we implement kernel-side setattr, |
|
320 | 320 | # this should probably be done that way, but for now this will do. |
|
321 | msg = self.session.msg('shutdown_request', {}) | |
|
321 | msg = self.session.msg('shutdown_request', {'restart':restart}) | |
|
322 | 322 | self._queue_request(msg) |
|
323 | 323 | return msg['header']['msg_id'] |
|
324 | 324 | |
@@ -743,7 +743,7 b' class KernelManager(HasTraits):' | |||
|
743 | 743 | self.rep_address = (LOCALHOST, req) |
|
744 | 744 | self.hb_address = (LOCALHOST, hb) |
|
745 | 745 | |
|
746 | def shutdown_kernel(self): | |
|
746 | def shutdown_kernel(self, restart=False): | |
|
747 | 747 | """ Attempts to the stop the kernel process cleanly. If the kernel |
|
748 | 748 | cannot be stopped, it is killed, if possible. |
|
749 | 749 | """ |
@@ -759,7 +759,7 b' class KernelManager(HasTraits):' | |||
|
759 | 759 | # Don't send any additional kernel kill messages immediately, to give |
|
760 | 760 | # the kernel a chance to properly execute shutdown actions. Wait for at |
|
761 | 761 | # most 1s, checking every 0.1s. |
|
762 | self.xreq_channel.shutdown() | |
|
762 | self.xreq_channel.shutdown(restart=restart) | |
|
763 | 763 | for i in range(10): |
|
764 | 764 | if self.is_alive: |
|
765 | 765 | time.sleep(0.1) |
@@ -793,7 +793,7 b' class KernelManager(HasTraits):' | |||
|
793 | 793 | if now: |
|
794 | 794 | self.kill_kernel() |
|
795 | 795 | else: |
|
796 | self.shutdown_kernel() | |
|
796 | self.shutdown_kernel(restart=True) | |
|
797 | 797 | self.start_kernel(**self._launch_args) |
|
798 | 798 | |
|
799 | 799 | # FIXME: Messages get dropped in Windows due to probable ZMQ bug |
@@ -167,6 +167,8 b' class Kernel(HasTraits):' | |||
|
167 | 167 | content = dict(parent['content']) |
|
168 | 168 | msg = self.session.send(self.reply_socket, 'shutdown_reply', |
|
169 | 169 | content, parent, ident) |
|
170 | msg = self.session.send(self.pub_socket, 'shutdown_reply', | |
|
171 | content, parent, ident) | |
|
170 | 172 | print >> sys.__stdout__, msg |
|
171 | 173 | time.sleep(0.1) |
|
172 | 174 | sys.exit(0) |
General Comments 0
You need to be logged in to leave comments.
Login now