How to use multiprocessing pool to call a method of a class which has parametrized constructor?
Below is my example program. Here I need to execute obj.api_call()
method in parallel using pool of worker processes.
import requests
class A:
def __init__(self, user):
self.user = user
def api_call(self):
url = "http://eample.com?name=" + self.user
print(url)
res = requests.get(url)
print(res)
name_list = ['ram', 'krish', 'shiv', 'david', 'rahul', 'gopal', 'vijay', 'sati']
for name in name_list:
obj = A(name)
obj.api_call()