Before, I were able to kill a python script started with execfile("somescript.py")
while in interpreter by pressing Ctrl + C
without killing the interpreter. This would cause a KeyboardInterrupt
exception that would stop the script and let me use the interpreter again. However, now (I suspect this came with newer version of python), when I press Ctrl + C
while running a script, it sometimes also kills the interpreter, throwing me back to Linux command line. For some reason this doesn't happen every time I kill a script with Ctrl + C
.
This is annoying because I often use python interpreter interactively, i.e. I run some script with execfile("somescript.py")
, play around with the data it produces in the interpreter, etc. Before, if some script got stuck, I was able to kill it and not lose the data it had calculated (or I had stored in variables) before getting stuck.
So my question is, how do I kill a python script started with execfile()
in the interpreter now without killing the interpreter?