How can I terminate a python program from an embedded IPython shell?
<p>I have the problem that for debugging purposes I drop into an IPython shell in a loop:</p>

<pre><code>for x in large_list:
  if x.looks_bad():
    import IPython
    IPython.embed()
</code></pre>

<p>From there I may want to terminate the <em>parent</em> program, because after debugging the problem cause, <code>embed()</code> would be called a lot of times.  <code>sys.exit(1)</code> is caught by IPython, so I cannot use that.</p>

<p><code>sys.exit</code> just raises the <code>SystemExit</code> exception.  The following works by hard-killing the program:</p>

<pre><code>import os
os._exit(1)
</code></pre>

python ipython