Modifiying global variables with multiprocessing
<p>I want to modify a list by appending to it items generated by some functions that work in parallel. Something like this:</p>

<pre><code>import multiprocessing
my_list=[]

def f(x):
    global my_list
    my_list.append(x)

for i in range(6):
    p = multiprocessing.Process(target=f, args=(i,))
    jobs.append(p)
    p.start()

for job in jobs:
    job.join()
</code></pre>

<p>I expect to see something like:</p>

<pre><code>In : my_list
Out: [0,1,2,3,4,5]
</code></pre>

<p>However the output is an empty list:</p>

<pre><code>In : my_list
Out: []
</code></pre>

<p>Do you know why this is happening and how can I adapt the code to make it modify the global variable?</p>