Why doesn't threading.join() return a value?

Carl Banks pavlovevidence at gmail.com
Sat Sep 3 08:04:42 EDT 2011


On Friday, September 2, 2011 11:01:17 AM UTC-7, Adam Skutt wrote:
> On Sep 2, 10:53 am, Roy Smith <r.... at panix.com> 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.
> 
> I assume it is because the underlying operating system APIs do not
> support it.

Nope.  This could easily be implemented by storing the return value in the Thread object.

It's not done that way probably because no one thought of doing it.


Carl Bannks



More information about the Python-list mailing list