I have a tasks which is a vector of Tasks.
If I use foreach(wait, tasks), then it will throw like this (which is expected behavior)
julia> fill_model_D_X!(inn, X)
rest = 1, j = 40304412
Warning: 1.760797410756771e9 terminate all solves
ERROR: TaskFailedException
Stacktrace:
[1] #wait#582
@ ./task.jl:363 [inlined]
[2] wait
@ ./task.jl:360 [inlined]
[3] foreach
@ ./abstractarray.jl:3188 [inlined]
[4] fill_model_D_X!(v::Vector{JuMP.Model}, X::Vector{NamedTuple})
@ Main ./REPL[40]:38
[5] top-level scope
@ REPL[59]:1
nested task error: UNKNOWN_RESULT_STATUSINTERRUPTED
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:44
[2] get_a_paired_block(O::Vector{Int64})
@ Main ./REPL[25]:53
[3] (::var"#fill_model_D_X!##0#fill_model_D_X!##1"{Vector{…}, Vector{…}, Base.Threads.Atomic{…}})(j::Int64)
@ Main ./REPL[40]:5
[4] (::var"#fill_model_D_X!##4#fill_model_D_X!##5"{Int64, var"#fill_model_D_X!##0#fill_model_D_X!##1"{…}})()
@ Main ./REPL[40]:14
However, If I just replace it with waitall(tasks), then the ERROR is not seen (which should exists).
julia> fill_model_D_X!(inn, X) # No ERROR here
rest = 1, j = 50990457
Warning: 1.760797120923299e9 terminate all solves
julia> for i = X # But it is indeed problematic, if I check it manually
end
ERROR: UndefRefError: access to undefined reference
I want to ask: is this normal? Why?
And, what’s the advantage of using waitall in favor of the old alternatives?