Leo Jay wrote: > Dear all, > > i would like to get the return value of all threads > > e.g. > def foo(num): > if num>10: > return 1 > elif num>50: > return 2 > else > return 0 > > > after i invoked > t = thread.start_new_thread(foo,(12,)) > how to get the return value of `foo'? Take a look at the Queue module. Create a queue instance at let the 'foo thread' put() its result into it: fooResult = Queue.Queue() def foo(num): result = 0 if num>10: result = 1 elif num>50: result = 2 fooResult.put(result) t = thread.start_new_thread(foo,(12,)) # do other stuff, foo is running in background r = fooResult.get() # guaranteed to block until result is available print r -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4