You need to change the line in the function fto:
d['i'] = [i]
to something like
d[str(i)] = i
so that your processes do not overwrite other entries in a shared dict. After that, it works fine for me (in Python 2.7.3), printing
{'1': 1, '0': 0, '3': 3, '2': 2, '4': 4}
( , , , import multiprocessing as mp)
: , shared dict , ,
d[str(i)] = [i]
, , , , , manager.list() , :
count = 5
lists = [manager.list() for i in range(count)]
for i in range(count):
d[i] = lists[i]
processes = [mp.Process(target=self.f, args=(d,i, lists)) for i in range(count)]
[...]
def f(self,d,i, lists):
for j in range(i):
lists[j].append(i)
dict, - , . , , , , . :
{0: [1, 2, 3, 4], 1: [2, 3, 4], 2: [3, 4], 3: [4], 4: []}