Why doesn't threading.join() return a value?
usenet-nospam at seebs.net
Fri Sep 2 18:42:34 CEST 2011
On 2011-09-02, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
> Roy Smith wrote:
>> I have a function I want to run in a thread and return a value. It
>> seems like the most obvious way to do this is to have my target
>> function return the value, the Thread object stash that someplace, and
>> return it as the return value for join().
>> Yes, I know there's other ways for a thread to return values (pass the
>> target a queue, for example), but making the return value of the
>> target function available would have been the most convenient. I'm
>> curious why threading wasn't implemented this way.
> Because then the code launching the thread would have to block, waiting
> until the thread is completed, so it will have a result to return.
Isn't "waiting until the thread is completed" sort of the point of join()?
Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam at seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
More information about the Python-list