python
try:
except ExceptionType:
python
import threading
import logging
def handle_thread_exception(exc_type, exc_value, exc_traceback):
logging.error("Unhandled exception", exc_info=(exc_type, exc_value, exc_traceback))
sys.excepthook = handle_thread_exception
class MyThread(threading.Thread):
def run(self):
try:
except Exception as e:
print("Caught exception:", e)
my_thread = MyThread()
my_thread.start()