Issue
I have the problem that for debugging purposes I drop into an IPython shell in a loop:
for x in large_list:
if x.looks_bad():
import IPython
IPython.embed()
From there I may want to terminate the parent program, because after debugging the problem cause, embed()
would be called a lot of times. sys.exit(1)
is caught by IPython, so I cannot use that.
Solution
sys.exit
just raises the SystemExit
exception. The following works by hard-killing the program:
import os
os._exit(1)
To easier find this in my IPython history with Ctrl-r exit
(the last line will not be saved to the history), I actually wrote this line once, with a deliberate typo:
import os; os._exit(1)_
Answered By - quazgar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.