I want to run a parfor loop which looks like this:
my_func_output = my_function;
The problem with my_function is, that it sometimes terminates, sometimes however doesn't and keeps running for an indefinite time. If ther function does not terminate within one minute, chances are it won't terminate at all. The function is from third-party software which I cannot edit.
I need to run the function 500 times and I have 10 workers at my disposal. However, when I start the loop, eventually all the workers get cluttered with functions which do not terminate and I do not get my results.
My idea was to run the parfor loop above, i.e. run the function on each of my 10 workers in parallel. If the worker should need more than one minute for the function, it should restart and start running the function again. Or in this case, just execute continue and move onto the next iteration of the parfor loop.
Is there a way to do this in Matlab?