Skip to content

Commit 9d865c8

Browse files
committed
Merge pull request ipython#1597 from minrk/while_eventloop
re-enter kernel.eventloop after catching SIGINT This protects the kernel from exiting due to bugs failing to catch SIGINT properly in the eventloop integration functions, as described in ipython#1228. It does not fix those bugs, only reduces the severity of their consequences.
2 parents a0e0f39 + d70249c commit 9d865c8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

IPython/zmq/ipkernel.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,17 @@ def start(self):
201201
# stop ignoring sigint, now that we are out of our own loop,
202202
# we don't want to prevent future code from handling it
203203
signal(SIGINT, default_int_handler)
204-
if self.eventloop is not None:
204+
while self.eventloop is not None:
205205
try:
206206
self.eventloop(self)
207207
except KeyboardInterrupt:
208208
# Ctrl-C shouldn't crash the kernel
209209
io.raw_print("KeyboardInterrupt caught in kernel")
210+
continue
211+
else:
212+
# eventloop exited cleanly, this means we should stop (right?)
213+
self.eventloop = None
214+
break
210215

211216

212217
def record_ports(self, ports):

0 commit comments

Comments
 (0)