title: Check if a python program exited with an exception
body: <p>I'm doing some processing in a <code>__del__()</code> destructor of a Python object that I don't want to happen if the program exited via exception. Is there a way to check from <code>__del__()</code> if I'm in the middle of normal exit or exception unwinding?</p>
  
  <p>Alternatively is there some way to check for the same condition in the <code>atexit</code> function?</p>