How to interrupt fun(a,b) in a for loop after 10 seconds?
If terminated before execution, fun x,y,z=false
for i=1:k
x,y,z=fun(a,b)
??? 10 sek > x,y,z=false,false,false
end
Thank you very much for your help, GPT doesnβt know but the matter is urgent!
Top comments (3)
You can use threads for this. Here is a simple example:
It doesn't interrupt the function
fun
but ignores the result if it takes longer than 10sec and proceeds in the main thread.You get faster (and better!) help on discourse:
discourse.julialang.org/
A link to the discourse discussion:
discourse.julialang.org/t/how-to-i...