Skip to content

Commit 5a381d2

Browse files
GregPlowmanStefanKarpinski
authored andcommitted
Capture pid in ProcessExitedException (#30733)
1 parent ca8abfe commit 5a381d2

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

stdlib/Distributed/src/cluster.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,20 +1030,23 @@ function _rmprocs(pids, waitfor)
10301030
end
10311031

10321032

1033-
struct ProcessExitedException <: Exception end
1034-
10351033
"""
1036-
ProcessExitedException()
1034+
ProcessExitedException(worker_id::Int)
10371035
10381036
After a client Julia process has exited, further attempts to reference the dead child will
10391037
throw this exception.
10401038
"""
1041-
ProcessExitedException()
1039+
struct ProcessExitedException <: Exception
1040+
worker_id::Int
1041+
end
1042+
1043+
# No-arg constructor added for compatibility with Julia 1.0 & 1.1, should be deprecated in the future
1044+
ProcessExitedException() = ProcessExitedException(-1)
10421045

10431046
worker_from_id(i) = worker_from_id(PGRP, i)
10441047
function worker_from_id(pg::ProcessGroup, i)
10451048
if !isempty(map_del_wrkr) && in(i, map_del_wrkr)
1046-
throw(ProcessExitedException())
1049+
throw(ProcessExitedException(i))
10471050
end
10481051
w = get(map_pid_wrkr, i, nothing)
10491052
if w === nothing
@@ -1137,7 +1140,7 @@ function deregister_worker(pg, pid)
11371140

11381141
# throw exception to tasks waiting for this pid
11391142
for (id, rv) in tonotify
1140-
close(rv.c, ProcessExitedException())
1143+
close(rv.c, ProcessExitedException(pid))
11411144
delete!(pg.refs, id)
11421145
end
11431146
end

stdlib/Distributed/src/precompile.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ precompile(Tuple{getfield(Distributed, Symbol("#kw##remote_do")), Array{Any, 1},
121121
precompile(Tuple{Type{Distributed.ResultMsg}, Distributed.RemoteException})
122122
precompile(Tuple{Type{Distributed.ResultMsg}, Symbol})
123123
precompile(Tuple{typeof(Distributed.send_msg_now), Sockets.TCPSocket, Distributed.MsgHeader, Distributed.ResultMsg})
124-
precompile(Tuple{typeof(Base.notify), Base.Condition, Distributed.ProcessExitedException, Bool, Bool})
125124
precompile(Tuple{typeof(Base.pop!), Base.Dict{Int64, Union{Distributed.Worker, Distributed.LocalProcess}}, Int64, Nothing})
126125
precompile(Tuple{typeof(Distributed.deregister_worker), Distributed.ProcessGroup, Int64})
127126
precompile(Tuple{typeof(Distributed.process_hdr), Sockets.TCPSocket, Bool})

0 commit comments

Comments
 (0)