Show More
@@ -15,6 +15,8 b'' | |||||
15 | import os |
|
15 | import os | |
16 | import re |
|
16 | import re | |
17 | import sys |
|
17 | import sys | |
|
18 | import signal | |||
|
19 | import time | |||
18 | from subprocess import Popen, PIPE |
|
20 | from subprocess import Popen, PIPE | |
19 |
|
21 | |||
20 | # Our own packages |
|
22 | # Our own packages | |
@@ -203,7 +205,22 b' class ScriptMagics(Magics, Configurable):' | |||||
203 | self.shell.user_ns[args.proc] = p |
|
205 | self.shell.user_ns[args.proc] = p | |
204 | return |
|
206 | return | |
205 |
|
207 | |||
206 | out, err = p.communicate(cell) |
|
208 | try: | |
|
209 | out, err = p.communicate(cell) | |||
|
210 | except KeyboardInterrupt: | |||
|
211 | p.send_signal(signal.SIGINT) | |||
|
212 | time.sleep(0.1) | |||
|
213 | if p.poll() is not None: | |||
|
214 | print "Process is interrupted." | |||
|
215 | return | |||
|
216 | p.terminate() | |||
|
217 | time.sleep(0.1) | |||
|
218 | if p.poll() is not None: | |||
|
219 | print "Process is terminated." | |||
|
220 | return | |||
|
221 | p.kill() | |||
|
222 | print "Process is killed." | |||
|
223 | return | |||
207 | out = py3compat.bytes_to_str(out) |
|
224 | out = py3compat.bytes_to_str(out) | |
208 | err = py3compat.bytes_to_str(err) |
|
225 | err = py3compat.bytes_to_str(err) | |
209 | if args.out: |
|
226 | if args.out: |
General Comments 0
You need to be logged in to leave comments.
Login now