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