consider the following objects:
class Item(object):
def __init__(self):
self.c = 0
def increase(self):
S.increase(self)
class S(object):
@staticmethod
def increase(item):
item.c += 1
This mirrors the situation I am currently in, S is some library class, Item collects and organises data and data manipulation processes. Now I want to parallelise the work, for that I use the python multiprocessing module:
from multiprocessing import Process
l= [Item() for i in range(5)]
for i in l:
Process(target=i.increase).start()
The result is not what I expected:
[i.c for i in l]
[0, 0, 0, 0, 0]
Where am I going wrong?