Kernel event loop is robust against random SIGINT. #472

Merged
merged 2 commits into from May 26, 2011
View
8 IPython/zmq/ipkernel.py
@@ -167,8 +167,12 @@ def start(self):
""" Start the kernel main loop.
"""
while True:
- time.sleep(self._poll_interval)
- self.do_one_iteration()
+ try:
+ time.sleep(self._poll_interval)
+ self.do_one_iteration()
+ except KeyboardInterrupt:
+ # Ctrl-C shouldn't crash the kernel
+ io.raw_print("KeyboardInterrupt caught in kernel")
def record_ports(self, xrep_port, pub_port, req_port, hb_port):
"""Record the ports that this kernel is using.