By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 906 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

retrieving a return code from a thread

P: n/a
hi all,

I would like to know how I can retrieve in my main program the
return code from a thread that I launched:
class example(threading.Thread):

def __init__(self, filename):
self.filename = filename
threading.Thread.__init__(self)
self.start()

def run(self):
........
rc = os.system("command example")

in the main thread:
......
thrdExample = []
thrdExample.append(example(file))
......
# once it's not active anymore, test of the return code for
thrdExample[i] ??

thanks in advance,
JY


Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You could use a synchronized Queue (look into the docs) where the running
thread(s) put their results. The main loop waits until some or all results
are there, and then continues processing.

--
Regards,

Diez B. Roggisch
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.