From f56f5a1c07b9dd49c80c87eb6426939322ff65f7 2012-05-15 00:27:33 From: MinRK Date: 2012-05-15 00:27:33 Subject: [PATCH] upstream change preventing kernel exit on SIGINT during eventloop integration. --- diff --git a/IPython/zmq/ipkernel.py b/IPython/zmq/ipkernel.py index 084a3e6..2c8f17d 100755 --- a/IPython/zmq/ipkernel.py +++ b/IPython/zmq/ipkernel.py @@ -243,7 +243,17 @@ class Kernel(Configurable): self.log.critical("entering eventloop") # restore default_int_handler signal(SIGINT, default_int_handler) - self.eventloop(self) + while self.eventloop is not None: + try: + self.eventloop(self) + except KeyboardInterrupt: + # Ctrl-C shouldn't crash the kernel + self.log.error("KeyboardInterrupt caught in kernel") + continue + else: + # eventloop exited cleanly, this means we should stop (right?) + self.eventloop = None + break self.log.critical("exiting eventloop") # if eventloop exits, IOLoop should stop ioloop.IOLoop.instance().stop()