I am trying to learn multiprocessing in python. I wrote 2 simple function and wanted to run both in parallel. I am getting TypeError: 'int' object is not callable.
Here is the code I have:
from multiprocessing import Process
def add(a):
t=0
for i in range(a):
t=i+1
return t
def subtract (b):
q=0
for j in range(b):
q=j+1
return (q)
a=100000000
b=100000000
p1 = Process(target=add(a))
p1.start()
print("r")
p2 = Process(target=subtract(b))
p2.start()
print("q")
p1.join()
p2.join()
This is the error log I get:
Process Process-24: TypeError: 'int' object is not callable Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap self.run() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 99, in run self._target(*self._args, **self._kwargs) r Process Process-25: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap self.run() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 99, in run self._target(*self._args, **self._kwargs) TypeError: 'int' object is not callable
Thanks.