Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: errors are emitted from asyncronous tasks #25

Merged
merged 4 commits into from
Mar 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/align.jl
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,6 @@ function align(Gs::Graph...; compare=Mash.distance, energy=(hit)->(-Inf), minblo
log("--> aligning pairs")

events = Channel{Bool}(10);
result = Channel{Graph}(1);

@spawn let
while isopen(events)
Expand All @@ -649,6 +648,9 @@ function align(Gs::Graph...; compare=Mash.distance, energy=(hit)->(-Inf), minblo
end
end

error_channel = Channel(1)

G = nothing
for clade ∈ postorder(tree)
@spawn try
if isleaf(clade)
Expand All @@ -667,16 +669,23 @@ function align(Gs::Graph...; compare=Mash.distance, energy=(hit)->(-Inf), minblo
if clade.parent !== nothing
put!(clade.parent.graph, G₀)
else
put!(result, G₀); close(result)
G = G₀
close(error_channel)
end
end
catch e
error(e)
catch err
put!(error_channel, [err, catch_backtrace()])
close(error_channel)
end
end

G = take!(result)
for (err, backtrace) in error_channel
@error "In-thread error during graph building:" exception=(err, backtrace)
error("graph construction failed, see above for stacktrace")
end

close(events)

return G
end

Expand Down