title: How to exit a loop on exception, but not re-raise every Exception type?
body: <p>I have a loop that I want to terminate on <code>KeyboardInterrupt</code>:</p>
  
  <pre><code>while True:
      try:
          do_stuff()
      except KeyboardInterrupt:
          cleanup()
          break
      except Exception as e:
          cleanup()
          raise e
  </code></pre>
  
  <p>This works fine, but the dual <code>cleanup()</code> seems very unclean to me. I don't like duplicated code. I tried using a context manager instead, but that introduced a lot of unnecessary complexity and nearly doubled the file size.</p>
  
  <p>Is there a cleaner way to express my intent?</p>