In fact it seems the issue is summarized by the following.
In a python shell I define a function:
Code:
>>> def myfct2(n):
... for i in range(len(n)):
... n[i] = i
... time.sleep(3)
Then execute it with a 'None' list:
Code:
N=[None]*4
>>> N
[None, None, None, None]
>>> myfct(N)
>>> N
[0, 1, 2, 3]
The list gets change because it's mutable.
Now, if I do the same thing in a process it behaves differently:
Code:
proc=multiprocessing.Process( target=myfct,args=(N,),daemon=True)
N=[None]*4
>>> proc.start()
>>> proc.is_alive()
True
>>> proc.is_alive()
True
>>> proc.is_alive()
True
>>> proc.is_alive()
True
>>> proc.is_alive()
True
>>> proc.is_alive()
False
>>> N
[None, None, None, None]
Can someone tell me how can I modify a mutable object passed to a function argument through a process ?