Python multiprocessing: Process object not callable
Question: So, recently, I've been experimenting with the multiprocessing module. I wrote
this script to test it:

    
    
    from multiprocessing import Process
    from time import sleep
    
    def a(x):
        sleep(x)
        print ("goo")
    
    a = Process(target=a(3))
    b = Process(target=a(5))
    c = Process(target=a(8))
    d = Process(target=a(10))
    
    if __name__ == "__main__":
        a.start()
        b.start()
        c.start()
        d.start()
    

However, when I try to run it, it throws this error:

    
    
    goo
    Traceback (most recent call last):
      File "C:\Users\Andrew Wong\Desktop\Python\test.py", line 9, in <module>
        b = Process(target=a(5))
    TypeError: 'Process' object is not callable
    

...And I can't tell what's going on. Does anyone know what happened, and how I
can fix it?


Answer: Pass arguments to the function that is ran by a `Process` is done differently
- looking at the
[documentation](https://docs.python.org/2/library/multiprocessing.html) it
shows:

    
    
    from multiprocessing import Process
    
    def f(name):
        print 'hello', name
    
    if __name__ == '__main__':
        p = Process(target=f, args=('bob',)) # that's how you should pass arguments
        p.start()
        p.join()
    

Or in your case:

    
    
    from multiprocessing import Process
    from time import sleep
    
    def a(x):
        sleep(x)
        print ("goo")
    
    e = Process(target=a, args=(3,))
    b = Process(target=a, args=(5,))
    c = Process(target=a, args=(8,))
    d = Process(target=a, args=(10,))
    
    if __name__ == "__main__":
        e.start()
        b.start()
        c.start()
        d.start()
    

**Addition:**  
Good catch by Luke (in the comments below) - you're overriding the function
`a` with the variable name `a` when doing:

    
    
    a = Process(target=a, args=(3,))
    

You should use a different name.

