J
Joe Wong
Hi,
I have a class that created a child thread for processing, this thread might raise an exception under some condition. On the main program that create an object of this case, I put a try/except block trying to capture the exception but failed. Am I doing anything wrong here?
here is the stripped version of my code:
class A:
def __init__(self):
self.thread = threading.Thread(None, self.MyThread)
self.thread.setDaemon(1)
self.thread.start()
def MyThread(self):
while 1:
# do something. if error:
if error:
raise exception
in my Main program:
main()
a = A()
while 1:
try:
# do something..
except exception, e:
# I should capture the exception from A, but not..
I have a class that created a child thread for processing, this thread might raise an exception under some condition. On the main program that create an object of this case, I put a try/except block trying to capture the exception but failed. Am I doing anything wrong here?
here is the stripped version of my code:
class A:
def __init__(self):
self.thread = threading.Thread(None, self.MyThread)
self.thread.setDaemon(1)
self.thread.start()
def MyThread(self):
while 1:
# do something. if error:
if error:
raise exception
in my Main program:
main()
a = A()
while 1:
try:
# do something..
except exception, e:
# I should capture the exception from A, but not..