I am using Python 2.5 and trying to use a self-defined excepthook in my program. In the main thread it works perfectly fine. But in a thread started with the threading module the usual excepthook is called.
Here is an example showing the problem. Uncommenting the comment shows the desired behaviour.
import threading, sys
def myexcepthook(type, value, tb):
    print 'myexcepthook'
class A(threading.Thread, object):
    def __init__(self):
        threading.Thread.__init__(self, verbose=True)
#       raise Exception('in main')
        self.start()
    def run(self):
        print 'A'
        raise Exception('in thread')            
if __name__ == "__main__":
    sys.excepthook = myexcepthook
    A()
So, how can I use my own excepthook in a thread?
 
     
     
     
     
    