I have a init method which initializes various primitive and complex data types and objects. In each process spawned by multiprocessing.Process, I'm printing a variable from init() method and an address of an initialized object. I get different instances of the variable but the address of object remains the same. So, want to know what exactly happens to members of parent class during multiprocessing.Process call?
def __init__(self):
self.count = 0
self.db = pymongo.MongoClient()
def consumerManager(self):
for i in range(4):
p = multiprocessing.Process(target = self.consumer, args = (i,))
def consumer(self, i):
while(1):
time.sleep(i)
self.count += 1
print self.count
print os.getpid()
print id(self.db)
If it is doing a deep copy of objects, then id(self.db)
should be printing a different id within each process, which doesn't happen. How does this done?