Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 207

How to get the return value from a thread?

$
0
0

The function foo below returns a string 'foo'. How can I get the value 'foo' which is returned from the thread's target?

from threading import Threaddef foo(bar):    print('hello {}'.format(bar))    return 'foo'thread = Thread(target=foo, args=('world!',))thread.start()return_value = thread.join()

The "one obvious way to do it", shown above, doesn't work: thread.join() returned None.


Viewing all articles
Browse latest Browse all 207

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>