Suppose I have a function like this:
def f(angle):
if angle % 5==0:
return angle
return None
Then I use joblib.Parallel and joblib.delayed in the following way:
from joblib import Parallel, delayed
results = Parallel(n_jobs=4)(delayed(f)(angle) for angle in range(360))
This gives me all values that I want and they will be different from "None" only when angle is divisible by 5. Then i do the following
for x in results:
if x is not None:
return x
With this I return first result that is not None. But, what if we need to do some hard calculations that takes too much time? Then we would want this to be finished during parallelization. I don't want to brute force all parallelization in order to find value that I want. I would like if I could obtain this value immidiately during parallelization, after which parallelization stops and gives me the value i want. What is the best way to accomplish that using joblib library?