I'm trying to parallelize a task that involves a function which takes a custom object as a parameter. During the body of the function, said object gets manipulated, so I need a deepcopy of the original object at the start of each trial. When I use the code below, the markers that show if the object is changed don't show until ~ trial 30. I suppose I'm confused about how to properly transfer a copied object through functools.partial.
Host
object_base = Object()
object.initialize()
pool = multiprocessing.Pool(processes = 8)
return pool.map(functools.partial(processTrial, deepcopy(object_base),
array1, array2), range(num_trials))
Worker
def processTrial(object, array1, array2, trial_number):
if object.property != []:
print '!!!!!!!!'
for i in xrange(len(array1)):
""" stuff including changing object.property """
As a side note, I also sometimes recieve the error "object instance as no attribute 'self' "... Any tips?