Show More
@@ -18,6 +18,7 b' For more details, see the ipython-zmq design' | |||
|
18 | 18 | from __future__ import print_function |
|
19 | 19 | |
|
20 | 20 | import bdb |
|
21 | import signal | |
|
21 | 22 | import sys |
|
22 | 23 | import time |
|
23 | 24 | |
@@ -169,8 +170,33 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):' | |||
|
169 | 170 | """ Method to capture raw_input |
|
170 | 171 | """ |
|
171 | 172 | msg_rep = self.km.stdin_channel.get_msg(timeout=timeout) |
|
173 | # in case any iopub came while we were waiting: | |
|
174 | self.handle_iopub() | |
|
172 | 175 |
if self.session_id == msg_rep["parent_header"]["session"] |
|
176 | # wrap SIGINT handler | |
|
177 | real_handler = signal.getsignal(signal.SIGINT) | |
|
178 | def double_int(sig,frame): | |
|
179 | # call real handler (forwards sigint to kernel), | |
|
180 | # then raise local interrupt, stopping local raw_input | |
|
181 | real_handler(sig,frame) | |
|
182 | raise KeyboardInterrupt | |
|
183 | signal.signal(signal.SIGINT, double_int) | |
|
184 | ||
|
185 | try: | |
|
173 | 186 | raw_data = raw_input(msg_rep["content"]["prompt"]) |
|
187 | except EOFError: | |
|
188 | # turn EOFError into EOF character | |
|
189 | raw_data = '\x04' | |
|
190 | except KeyboardInterrupt: | |
|
191 | sys.stdout.write('\n') | |
|
192 | return | |
|
193 | finally: | |
|
194 | # restore SIGINT handler | |
|
195 | signal.signal(signal.SIGINT, real_handler) | |
|
196 | ||
|
197 | # only send stdin reply if there *was not* another request | |
|
198 | # or execution finished while we were reading. | |
|
199 | if not (self.km.stdin_channel.msg_ready() or self.km.shell_channel.msg_ready()): | |
|
174 | 200 | self.km.stdin_channel.input(raw_data) |
|
175 | 201 | |
|
176 | 202 | def mainloop(self, display_banner=False): |
General Comments 0
You need to be logged in to leave comments.
Login now