I would like to excecute a function multiple times on different threads with different function inputs.
The problem is, that my function needs for every run more than just one input, so I am trying to do the following: (the function is much simplified here)
import time
from joblib import Parallel, delayed
# A function that can be called to do work:
def work(arg1,arg2):
return (arg1, arg2)
# List of arguments to pass to work():
arg_instances = [(1, 1), (1, 2), (1, 3), (1, 4)]
# Anything returned by work() can be stored:
results = Parallel(n_jobs=4, verbose=1, backend="threading")(map(delayed(work), arg_instances))
print(results)
Unfortunately it does not work.
work() missing 1 required positional argument: 'arg2'
It has something to do with the map function, but I don't know how to solve that. Any help would be much appreciated.