I have a Julia script that re-calls a C ++ program to optimize. The C ++ program writes a text file, then I read the results of Julia and decided what to do next. The problem is that from time to time (maybe 1 in 1000+ times) the C ++ program freezes (optimization probably gets stuck) and my whole script hangs indefinitely, which makes it very difficult for the script to do this through all the necessary calls program. Is there a way to add a timeout so that if the program does not end within 10 minutes, can I restart it with a new guess value?
A simplified example:
for k = 1:10
run(`program inputs`)
end
Desired:
max_runtime = 10*60
for k = 1:10
run(`program inputs`,max_runtime)
end
Alternative:
max_runtime = 10*60
for k = 1:10
deadline(function,max_runtime)
end
source
share