views:

922

answers:

2

I am subclassing the Process class, into a class I call EdgeRenderer. I want to use multiprocessing.Pool, except instead of regular Processes, I want them to be instances of my EdgeRenderer. Possible? How?

+1  A: 

I don't see any hook for it in the API. You might be able to get away with replicating your desired functionality by using initializer and initargs argument. Alternately, you can build the functionality into the callable object that you use for mapping:

class EdgeRenderTask(object):
    def op1(self,*args):
        ...
    def op2(self,*args):
        ...
p = Pool(processes = 10)
e = EdgeRenderTask()
p.apply_async(e.op1,arg_list)
p.map(e.op2,arg_list)
David Berger
+1  A: 

From Jesse Noller:

It is not currently supported in the API, but would not be a bad addition. I'll look at adding it to python2.7/2.6.3 3.1 this week

cool-RR