Is it possible to multiprocess a function that returns something in Python?

multiprocessing, python

Solution

Yes, sure - you can use a number of methods. One of the easiest ones is a shared `Queue`. See an example here: http://eli.thegreenplace.net/2012/01/16/python-parallelizing-cpu-bound-tasks-with-multiprocessing/

Problem

In Python I have seen many examples where multiprocessing is called but the target just prints something. I have a scenario where the target returns 2 variables, which I need to use later. For example: ``` def foo(some args): a = someObject b = someObject return a,b p1=multiprocess(target=foo,args(some args)) p2=multiprocess(target=foo,args(some args)) p3=multiprocess(target=foo,args(some args)) ``` Now what? I can do .start and .join, but how do I retrieve the individual results? I need to catch the return a,b for all the jobs I execute and then work on it.

Original source