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

Carl Banks pavlovevidence at gmail.com
Sat Sep 3 14:27:51 CEST 2011

On Friday, September 2, 2011 11:53:43 AM UTC-7, Adam Skutt wrote:
> On Sep 2, 2:23 pm, Alain Ketterlin <al... at dpt-info.u-strasbg.fr>
> wrote:
> > Sorry, you're wrong, at least for POSIX threads:
> >
> > void pthread_exit(void *value_ptr);
> > int pthread_join(pthread_t thread, void **value_ptr);
> >
> > pthread_exit can pass anything, and that value will be retrieved with
> > pthread_join.
> No, it can only pass a void*, which isn't much better than passing an
> int.  Passing a void* is not equivalent to passing anything, not even
> in C.  Moreover, specific values are still reserved, like
> PTHREAD_CANCELLED. Yes, it was strictly inappropriate for me to say
> both return solely integers, but my error doesn't meaningful alter my
> description of the situation.  The interface provided by the
> underlying APIs is not especially usable for arbitrary data transfer.

I'm sorry, but your claim is flat out wrong.  It's very common in C programming to use a void* to give a programmer ability to pass arbitrary data through some third-party code.

The Python API itself uses void* in this way in several different places.  For instance, ake a look at the Capsule API (http://docs.python.org/c-api/capsule.html).  You'll notice it uses a void* to let a user pass in opaque data.  Another case is when declaring properties in C: it's common to define a single get or set function, and only vary some piece of data for the different properties.  The API provides a void* so that the extension writer can pass arbitrary data to the get and set functions.

Carl Banks

More information about the Python-list mailing list