Skip to content

Commit

Permalink
Capture pid in ProcessExitedException (JuliaLang#30733)
Browse files Browse the repository at this point in the history
  • Loading branch information
GregPlowman authored and StefanKarpinski committed Apr 8, 2019
1 parent ca8abfe commit 5a381d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 9 additions & 6 deletions stdlib/Distributed/src/cluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1030,20 +1030,23 @@ function _rmprocs(pids, waitfor)
end


struct ProcessExitedException <: Exception end

"""
ProcessExitedException()
ProcessExitedException(worker_id::Int)
After a client Julia process has exited, further attempts to reference the dead child will
throw this exception.
"""
ProcessExitedException()
struct ProcessExitedException <: Exception
worker_id::Int
end

# No-arg constructor added for compatibility with Julia 1.0 & 1.1, should be deprecated in the future
ProcessExitedException() = ProcessExitedException(-1)

worker_from_id(i) = worker_from_id(PGRP, i)
function worker_from_id(pg::ProcessGroup, i)
if !isempty(map_del_wrkr) && in(i, map_del_wrkr)
throw(ProcessExitedException())
throw(ProcessExitedException(i))
end
w = get(map_pid_wrkr, i, nothing)
if w === nothing
Expand Down Expand Up @@ -1137,7 +1140,7 @@ function deregister_worker(pg, pid)

# throw exception to tasks waiting for this pid
for (id, rv) in tonotify
close(rv.c, ProcessExitedException())
close(rv.c, ProcessExitedException(pid))
delete!(pg.refs, id)
end
end
Expand Down
1 change: 0 additions & 1 deletion stdlib/Distributed/src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ precompile(Tuple{getfield(Distributed, Symbol("#kw##remote_do")), Array{Any, 1},
precompile(Tuple{Type{Distributed.ResultMsg}, Distributed.RemoteException})
precompile(Tuple{Type{Distributed.ResultMsg}, Symbol})
precompile(Tuple{typeof(Distributed.send_msg_now), Sockets.TCPSocket, Distributed.MsgHeader, Distributed.ResultMsg})
precompile(Tuple{typeof(Base.notify), Base.Condition, Distributed.ProcessExitedException, Bool, Bool})
precompile(Tuple{typeof(Base.pop!), Base.Dict{Int64, Union{Distributed.Worker, Distributed.LocalProcess}}, Int64, Nothing})
precompile(Tuple{typeof(Distributed.deregister_worker), Distributed.ProcessGroup, Int64})
precompile(Tuple{typeof(Distributed.process_hdr), Sockets.TCPSocket, Bool})
Expand Down

0 comments on commit 5a381d2

Please sign in to comment.