You need a couple of things to get your code working as you expect.
First: Add to your thread instance an attribute result
and some access method.
import threading
class YourThread(threading.Thread):
... # code you already have.
self.__result # code I'm suggesting.
def get_result(self):
return self.__result
def run(self):
# You have to modify the code in your run method in order to provide
# a value for self.__result.
Second: You main thread has to wait
for myMailInstance
ends, and then ask for the result. So, you need to call join
on your thread.
myMailInstance.start()
logging.debug('This message should be printed before the mail thread ends')
myMailInstance.join()
if myMailInstance.get_result() == 0:
logging.debug('Success')
elif myMailInstance.get_result() == 1:
logging.debug('Failed')
That's all.