Python multiprocessing - probably failure when method name pass to Process
Question: I have problem with multiprocessing. Under you have the code (he's in couple
of class and files, but i simplified it). I suppose, that problem lies in pass
method name which I want to multiply in multiprocessing.  
Informations: "args" is a list like as [(0,1),(1,2),(2,3)] so single "arg"
like as (0,1) This two files are in totally other calatogs  
!!First file!!

    
    
    from ... import EF
    from ... import someclass
    
    class performs():
        def action():
            for i, arg in enumerate(args):
                data.append(EF(self.method,list(arg),i))
            someclass.create_processes(*data)
    
        def method(self,fa,la):
            ...
    

!!second file!!

    
    
    from multiprocessing import Process,Event
    class EF(object):
        def __init__(self,name,args=list(),proc=1):
            self.name=name
            self.args=args
            self.proc=proc
    
    class someclass:
        @staticmethod
        def create_processes(*functions):
            processes=dict()
            for function in functions:
                process=Process(target=function.name,args=function.args)
                process.start()
                processes[process.pid]=process
            for process in processes.values():
                process.join()
    

When I'm debugging, error comes, when program performing this instruction
"process.start()"

Console:

    
    
    File "C:\Python32\lib\multiprocessing\forking.py", line 371, in main
        self = load(from_parent)
    AttributeError: 'performs' object has no attribute 'function'
    

or in other situation

    
    
    File "C:\Python32\lib\multiprocessing\process.py", line 267, in _bootstrap
        self.run()
      File "C:\Python32\lib\multiprocessing\process.py", line 116, in run
        self._target(*self._args, **self._kwargs)
      File "...\performs.py", line 88, in method
    ...
    

I don't know it's important, but I have 64bit system, and installed Python and
accesories for 32 bit


Answer: The comment box is too small for this, but it seems like your code is working
fine. I tested it by copying it in two files (like your environment), but it
of course also works in a single file. That file you can find below: it is
working as expected (save for the print statements output being mixed up, but
that is to be expected).

So, most likely, your issue lies elsewhere? The error seems to indicate
perhaps some inclusion order, like stated in [this
question](http://stackoverflow.com/questions/2782961/yet-another-confusion-
with-multiprocessing-error-module-object-has-no-attribu)?

    
    
    from multiprocessing import Process,Event
    
    class EF:
        def __init__(self, name, args=list(), proc=1):
            self.name = name
            self.args = args
            self.proc = proc
    
    class someclass:
        @staticmethod
        def create_processes(*functions):
            processes=dict()
            for function in functions:
                process=Process(target=function.name,args=function.args)
                process.start()
                processes[process.pid]=process
            for process in processes.values():
                process.join()
    
    class performs:
        def action(self, args):
            data = []
            for i, arg in enumerate(args):
                data.append(EF(self.mult, list(arg), i))
            someclass.create_processes(*data)
    
        def mult(self,fa,la):
            print '%d x %d = %d' % (fa, la, fa * la)
    
    if __name__ == '__main__':
        p = performs()
        p.action([(x, x+1) for x in xrange(10)])
    

