diff --git a/Project.toml b/Project.toml index 5c2a6ad..72d7b83 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Malt" uuid = "36869731-bdee-424d-aa32-cab38c994e3b" authors = ["Sergio Alejandro Vargas "] -version = "1.1.0" +version = "1.1.1" [deps] Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" diff --git a/src/worker.jl b/src/worker.jl index 0aa8240..82ebe52 100644 --- a/src/worker.jl +++ b/src/worker.jl @@ -75,9 +75,9 @@ function serve(server::Sockets.TCPServer) msg_id = read(io, MsgID) msg_data, success = try - deserialize(io), true + (deserialize(io), true) catch err - err, false + (format_error(err, catch_backtrace()), false) finally _discard_until_boundary(io) end @@ -116,16 +116,14 @@ function handle(::Val{MsgType.from_host_call_with_response}, socket, msg, msg_id f, args, kwargs, respond_with_nothing = msg @async begin - success, result = try + result, success = try result = f(args...; kwargs...) # @debug("WORKER: Evaluated result", result) - (true, respond_with_nothing ? nothing : result) - catch e + (respond_with_nothing ? nothing : result, true) + catch err # @debug("WORKER: Got exception!", e) - (false, sprint() do io - Base.invokelatest(showerror, io, e, catch_backtrace()) - end) + (format_error(err, catch_backtrace()), false) end _serialize_msg( @@ -158,9 +156,12 @@ function handle(::Val{MsgType.special_serialization_failure}, socket, msg, msg_i ) end +format_error(err, bt) = sprint() do io + Base.invokelatest(showerror, io, err, bt) +end + const _channel_cache = Dict{UInt64, AbstractChannel}() if abspath(PROGRAM_FILE) == @__FILE__ main() end - diff --git a/test/exceptions.jl b/test/exceptions.jl index 60c8c74..98c4dc8 100644 --- a/test/exceptions.jl +++ b/test/exceptions.jl @@ -13,6 +13,9 @@ macro catcherror(ex) end end +# To test serialization +struct LocalStruct end + # @testset "Exceptions" begin @testset "Exceptions: $W" for W in ( m.DistributedStdlibWorker, @@ -132,6 +135,12 @@ end @test m.remote_call_fetch(&, w, true, true) end + W === m.Worker && @testset "Serialization error" begin + @test_throws m.RemoteException m.remote_eval_fetch(w, quote + $(LocalStruct)() + end) + end + # The worker should be able to handle all that throwing @test m.isrunning(w)