I'm using Pool to multithread my programme using starmap to pass arguments.
I'm stuck because I cannot seem to find a way to pass kwargs along with the zip arrays that I'm passing in the starmap function.
pool = Pool(NO_OF_PROCESSES)
branches = pool.starmap(fetch_api, zip(repeat(project_name), api_extensions))
The branches request is incomplete as I'm still not able to figure out how to pass keywords arguments.
def fetch_api(project_name, api_extension, payload={}, headers={}, API_LINK=API_LINK, key=False):
headers[AUTH_STRING] = 'Gogo'
call_api = API_LINK + project_name + api_extension
response_api = requests.get(call_api, headers=headers, params=payload)
if key: return project_name + ':' + response_api
else: return response_api
While calling fetch_api() from the branch line, I want to pass payload as {'a':1} and key=True.
Please guide me to the direction or answer. Thanks. Using Python 3.3+.