I would like to handle the exception raised in a thread in the function in which it was started.
def thread_fn():
while True:
...
raise Exception('Exception occurred !!!!')
def main():
t = threading.Thread(target=thread_fn)
t.start()
try:
...
...
except Exception as e:
print(e.message)
# Expecting the exception raised by thread_fn
As above code states, the exception raised by thread_fn should be caught in main.