##// END OF EJS Templates
Avoid error while killing subprocess in %%script
Takafumi Arakaki -
Show More
@@ -208,18 +208,21 b' class ScriptMagics(Magics, Configurable):'
208 try:
208 try:
209 out, err = p.communicate(cell)
209 out, err = p.communicate(cell)
210 except KeyboardInterrupt:
210 except KeyboardInterrupt:
211 p.send_signal(signal.SIGINT)
211 try:
212 time.sleep(0.1)
212 p.send_signal(signal.SIGINT)
213 if p.poll() is not None:
213 time.sleep(0.1)
214 print "Process is interrupted."
214 if p.poll() is not None:
215 return
215 print "Process is interrupted."
216 p.terminate()
216 return
217 time.sleep(0.1)
217 p.terminate()
218 if p.poll() is not None:
218 time.sleep(0.1)
219 print "Process is terminated."
219 if p.poll() is not None:
220 return
220 print "Process is terminated."
221 p.kill()
221 return
222 print "Process is killed."
222 p.kill()
223 print "Process is killed."
224 except:
225 print "Failed to kill process properly (pid={0})".format(p.pid)
223 return
226 return
224 out = py3compat.bytes_to_str(out)
227 out = py3compat.bytes_to_str(out)
225 err = py3compat.bytes_to_str(err)
228 err = py3compat.bytes_to_str(err)
General Comments 0
You need to be logged in to leave comments. Login now