I have been trying the following:
from multiprocessing import Pool
def f(some_list):
some_list.append(4)
print 'Child process: new list = ' + str(some_list)
return True
if __name__ == '__main__':
my_list = [1, 2, 3]
pool = Pool(processes=4)
result = pool.apply_async(f, [my_list])
result.get()
print 'Parent process: new list = ' + str(my_list)
What I get is:
Child process: new list = [1, 2, 3, 4]
Parent process: new list = [1, 2, 3]
So, it means that the my_list was passed by value since it did not mutate. So, is the rule that it is really passed by value when passed to another process? Thanks.