python - Create exception hook in a thread -


the following code works when put in main module, exception hook not called when error occurs in thread, not if put code second time within thread.

any suggestions why?

import sys def myexcepthook(exctype, value, traceback):     if exctype == keyboardinterrupt:         print "handler code goes here"     else:         sys.__excepthook__(exctype, value, traceback)  sys.excepthook = myexcepthook 

the thread called follows:

t1 = threadmanager(1, "thread-1", 1) t1.start()   class threadmanager(threading.thread):     def run(self):         print 9_) # should cause error ic caught hook 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -