From 6a1593e3f1e7e1b5a93df5a19775a219dfde5450 Mon Sep 17 00:00:00 2001 From: Sergio Alejandro Vargas Date: Wed, 21 Sep 2022 20:18:59 -0500 Subject: [PATCH] Fix windows ECONNRESET bug Don't close sockets eagerly. Let GC handle it. --- src/Malt.jl | 3 --- src/worker.jl | 8 +++----- test/runtests.jl | 4 ++-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Malt.jl b/src/Malt.jl index 5eccd74..a4d411a 100644 --- a/src/Malt.jl +++ b/src/Malt.jl @@ -91,8 +91,6 @@ function _recv(socket) response.result catch e rethrow(e) - finally - close(socket) end end @@ -225,7 +223,6 @@ function worker_channel(w::Worker, expr)::Channel while isopen(channel) && isopen(s) put!(channel, deserialize(s)) end - close(s) return end) end diff --git a/src/worker.jl b/src/worker.jl index e08fe14..cd4e6b7 100644 --- a/src/worker.jl +++ b/src/worker.jl @@ -58,16 +58,14 @@ function handle(::Val{:call}, socket, msg) catch e # @debug("Exception!", e) serialize(socket, (status=:err, result=e)) - finally - close(socket) end end function handle(::Val{:remote_do}, socket, msg) try msg.f(msg.args...; msg.kwargs...) - finally - close(socket) + catch e + nothing end end @@ -76,7 +74,7 @@ function handle(::Val{:channel}, socket, msg) while isopen(channel) && isopen(socket) serialize(socket, take!(channel)) end - isopen(socket) && close(socket) + isopen(channel) && close(channel) return end diff --git a/test/runtests.jl b/test/runtests.jl index 3b99a73..ca5ac89 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -13,7 +13,7 @@ using Test # Terminating workers takes about 0.5s m.stop(w) - sleep(1) + sleep(2) @test m.isrunning(w) === false end @@ -74,7 +74,7 @@ end @test m.isrunning(w) === true m.stop(w) - sleep(1) + sleep(2) @test m.isrunning(w) === false end