Show More
@@ -22,6 +22,8 b' from IPython.frontend.terminal.ipapp import TerminalIPythonApp, frontend_flags a' | |||||
22 | from IPython.utils.traitlets import ( |
|
22 | from IPython.utils.traitlets import ( | |
23 | Dict, List, Unicode, Int, CaselessStrEnum, CBool, Any |
|
23 | Dict, List, Unicode, Int, CaselessStrEnum, CBool, Any | |
24 | ) |
|
24 | ) | |
|
25 | from IPython.utils.warn import warn,error | |||
|
26 | ||||
25 | from IPython.zmq.ipkernel import IPKernelApp |
|
27 | from IPython.zmq.ipkernel import IPKernelApp | |
26 | from IPython.zmq.session import Session, default_secure |
|
28 | from IPython.zmq.session import Session, default_secure | |
27 | from IPython.zmq.zmqshell import ZMQInteractiveShell |
|
29 | from IPython.zmq.zmqshell import ZMQInteractiveShell | |
@@ -114,12 +116,22 b' class ZMQTerminalIPythonApp(TerminalIPythonApp, IPythonMixinConsoleApp):' | |||||
114 | ipython_dir=self.ipython_dir, kernel_manager=self.kernel_manager) |
|
116 | ipython_dir=self.ipython_dir, kernel_manager=self.kernel_manager) | |
115 |
|
117 | |||
116 | def handle_sigint(self, *args): |
|
118 | def handle_sigint(self, *args): | |
117 | self.shell.write('KeyboardInterrupt\n') |
|
119 | if self.shell._executing: | |
118 | if self.kernel_manager.has_kernel: |
|
120 | if self.kernel_manager.has_kernel: | |
119 | self.kernel_manager.interrupt_kernel() |
|
121 | # interrupt already gets passed to subprocess by signal handler. | |
|
122 | # Only if we prevent that should we need to explicitly call | |||
|
123 | # interrupt_kernel, until which time, this would result in a | |||
|
124 | # double-interrupt: | |||
|
125 | # self.kernel_manager.interrupt_kernel() | |||
|
126 | pass | |||
|
127 | else: | |||
|
128 | self.shell.write_err('\n') | |||
|
129 | error("Cannot interrupt kernels we didn't start.\n") | |||
120 | else: |
|
130 | else: | |
121 | print 'Kernel process is either remote or unspecified.', |
|
131 | # raise the KeyboardInterrupt if we aren't waiting for execution, | |
122 | print 'Cannot interrupt.' |
|
132 | # so that the interact loop advances, and prompt is redrawn, etc. | |
|
133 | raise KeyboardInterrupt | |||
|
134 | ||||
123 |
|
135 | |||
124 | def init_code(self): |
|
136 | def init_code(self): | |
125 | # no-op in the frontend, code gets run in the backend |
|
137 | # no-op in the frontend, code gets run in the backend |
@@ -198,6 +198,9 b' class Kernel(Configurable):' | |||||
198 | except KeyboardInterrupt: |
|
198 | except KeyboardInterrupt: | |
199 | # Ctrl-C shouldn't crash the kernel |
|
199 | # Ctrl-C shouldn't crash the kernel | |
200 | io.raw_print("KeyboardInterrupt caught in kernel") |
|
200 | io.raw_print("KeyboardInterrupt caught in kernel") | |
|
201 | # stop ignoring sigint, now that we are out of our own loop, | |||
|
202 | # we don't want to prevent future code from handling it | |||
|
203 | signal(SIGINT, default_int_handler) | |||
201 | if self.eventloop is not None: |
|
204 | if self.eventloop is not None: | |
202 | try: |
|
205 | try: | |
203 | self.eventloop(self) |
|
206 | self.eventloop(self) |
General Comments 0
You need to be logged in to leave comments.
Login now