[Python-Dev] Slides from today's parallel/async Python talk

Charles-François Natali cf.natali at gmail.com
Fri Apr 5 08:53:01 CEST 2013


>> async.submit_work(func, args, kwds, callback=None, errback=None)
>> How do you implement arguments passing and return value?
>> e.g. let's say I pass a list as argument: how do you iterate on the
>> list from the worker thread without modifying the backing objects for
>> refcounts (IIUC you use a per-thread heap and don't do any
>> refcounting).
>     Correct, nothing special is done for the arguments (apart from
>     incref'ing them in the main thread before kicking off the parallel
>     thread (then decref'ing them in the main thread once we're sure the
>     parallel thread has finished)).

IIUC you incref the argument from the main thread before publishing it
to the worker thread: but what about containers like list? How do you
make sure the refcounts of the elements don't get deallocated while
the worker thread iterates? More generally, how do you deal with
non-local objects?

BTW I don't know if you did, but you could probably have a look at
Go's goroutines and Erlang processes.


More information about the Python-Dev mailing list