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

Rethrow exit loop interrupt to REPL #79

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/Malt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ mutable struct Worker <: AbstractWorker
)
atexit(() -> stop(w))

_exit_loop(w)
_detect_worker_exit_loop(w)
_receive_loop(w)

return w
Expand All @@ -146,8 +146,8 @@ Base.summary(io::IO, w::Worker) = write(io, "Malt.Worker on port $(w.port) with



function _exit_loop(worker::Worker)
@async for _i in Iterators.countfrom(1)
function _detect_worker_exit_loop(worker::Worker)
@async while true
try
if !isrunning(worker)
# the worker got shut down, which means that we will never receive one of the expected_replies. So let's give all of them a special_worker_terminated reply.
Expand All @@ -158,7 +158,12 @@ function _exit_loop(worker::Worker)
end
sleep(1)
catch e
@error "Unexpection error inside the exit loop" worker exception=(e,catch_backtrace())
if e isa InterruptException
@debug("HOST: Caught interrupt while waiting for worker exit, rethrowing to REPL...")
_rethrow_to_repl(e; rethrow_regular=false)
else
@error "Unexpection error inside the exit loop" worker exception=(e,catch_backtrace())
end
end
end
end
Expand Down
Loading