This is an old topic, but I have the very same issue with async tasks: they don’t show a useful stacktrace be default. Not only @async
itself, but also e.g. asyncmap
:
asyncmap(0:10) do i
1 ÷ i
end
ERROR: DivideError: integer division error
Stacktrace:
[1] (::Base.var"#770#772")(::Task) at ./asyncmap.jl:178
[2] foreach(::Base.var"#770#772", ::Array{Any,1}) at ./abstractarray.jl:2009
[3] maptwice(::Function, ::Channel{Any}, ::Array{Any,1}, ::UnitRange{Int64}) at ./asyncmap.jl:178
[4] wrap_n_exec_twice at ./asyncmap.jl:154 [inlined]
[5] #async_usemap#755 at ./asyncmap.jl:103 [inlined]
[6] #asyncmap#754 at ./asyncmap.jl:81 [inlined]
[7] asyncmap(::Function, ::UnitRange{Int64}) at ./asyncmap.jl:81
[8] top-level scope at REPL[3]:1
compare to map
:
map(0:10) do i
1 ÷ i
end
ERROR: DivideError: integer division error
Stacktrace:
[1] div at ./int.jl:260 [inlined]
[2] #13 at ./REPL[4]:2 [inlined]
[3] iterate at ./generator.jl:47 [inlined]
[4] _collect(::UnitRange{Int64}, ::Base.Generator{UnitRange{Int64},var"#13#14"}, ::Base.EltypeUnknown, ::Base.HasShape{1}) at ./array.jl:699
[5] collect_similar(::UnitRange{Int64}, ::Base.Generator{UnitRange{Int64},var"#13#14"}) at ./array.jl:628
[6] map(::Function, ::UnitRange{Int64}) at ./abstractarray.jl:2162
[7] top-level scope at REPL[4]:1
Is there any way to force the stacktrace go further than the asyncmap
internals, i.e. to the actual user function? I can only imagine putting try ... catch ... end
there manually.