I've a function that runs multiple queries in parallel but I'm having some troubles to run my function using multprocessing with more than argument. I've this code:
def run(args):
query, cursor = args
cursor.execute(query)
with multiprocessing.Pool(processes=10) as pool:
args = (product(queries),cursor)
results = pool.starmap(run(args))
If I run only pool.starmap(run(product(queries)))
it works well, however I have the need to pass also the cursor object.
How I can do that?
I'm having the following error:
TypeError: starmap() missing 1 required positional argument: 'iterable'