I need to append objects to one list L
from different processes using multiprocessing , but it returns empty list.
How can I let many processes append to list L
using multiprocessing?
#!/usr/bin/python
from multiprocessing import Process
L=[]
def dothing(i,j):
L.append("anything")
print i
if __name__ == "__main__":
processes=[]
for i in range(5):
p=Process(target=dothing,args=(i,None))
p.start()
processes.append(p)
for p in processes:
p.join()
print L
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…