I previously asked a question about updating a single value in a parallel process from a parent program. Great answers to this can be found at Python: Update Local Variable in a Parallel Process from Parent Program. Now I would like to extend this question to arrays. Say I have the following simple program that iterates through the first cell of an defined array (similar to the link provided):
import time
def loop(i):
while 1:
print i[0]
i[0] += 1
time.sleep(1)
if __name__ == "__main__":
from multiprocessing import Process, Array
i = Array("i", [1,2,3,4])
p = Process(target=loop, args=(i,))
p.start()
time.sleep(2)
# update i in shared memory???
From this program, how can I update "i" so the "loop" function continues to run and reads the new array? For example, if I want to set "i" to [50,51,52,53]. Is there an equivalent attribute like "value" that can do this? I did much searching around and could not find any solutions. Thank you very much in advance.