Skip to content

Commit

Permalink
Use message instead of interrupt for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
savq committed Sep 24, 2022
1 parent 3089ff4 commit 06d3327
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/Malt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,13 @@ kill(w::Worker) = Base.kill(w.proc)
Send an interrupt signal to the worker process. This will interrupt the
latest request (`remotecall*` or `remote_eval*`) that was sent to the worker.
"""
interrupt(w::Worker) = Base.kill(w.proc, Base.SIGINT)
function interrupt(w::Worker)
if Sys.iswindows()
isrunning(w) || throw(TerminatedWorkerException())
_send_msg(w.port, (header=:interrupt,))
else
Base.kill(w.proc, Base.SIGINT)
end
end

end # module
10 changes: 8 additions & 2 deletions src/worker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ function serve(server::Sockets.TCPServer)
# Handle request asynchronously
latest = @async begin
msg = deserialize(sock)
@debug(msg)
handle(Val(msg.header), sock, msg)
if get(msg, :header, nothing) === :interrupt
if latest isa Task && !istaskdone(latest)
Base.throwto(latest, InterruptException)
end
else
@debug(msg)
handle(Val(msg.header), sock, msg)
end
end
catch InterruptException
# Rethrow interrupt in the latest task
Expand Down

0 comments on commit 06d3327

Please sign in to comment.