title: Change default behavior of uncaught exception handling in python
body: <p>I went through "<a href="https://stackoverflow.com/questions/6234405/logging-uncaught-exceptions-in-python">Logging uncaught exceptions in Python</a>". And, I have tried this:</p>
  
  <pre><code>import web
  import sys
  
  app = web.application((
    '/test', 'test'), globals())
  
  def test_func(e_type, value, traceback):
    print "Handled exception here.."
  
  class test:
    def GET(self):
      a = 1/0
  
  if __name__ == "__main__":
    sys.excepthook = test_func
    app.run()
  </code></pre>
  
  <p>Here, you can easily see if <code>GET /test</code> request comes in, I am deliberately raising <code>ZerDivisionError</code>. As i have overriden <code>sys.excepthook</code>, I expect method <code>test_func</code> to execute on <code>ZeroDivisionError</code>.</p>
  
  <p>Whereas, this piece of code is not working as per expectation. I have observed that when i try to override <code>excepthook</code> in standalone code (not in web-app), it works fine. New method(overriden) is called properly.</p>
  
  <p>Any idea why is this different behavior ?</p>