Skip to content

Commit d4d21d3

Browse files
committed
fixup! Add support for worker statuses
1 parent 7b29d63 commit d4d21d3

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/cluster.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ const HDR_COOKIE_LEN = 16
891891
const map_pid_wrkr = Lockable(Dict{Int, Union{Worker, LocalProcess}}())
892892
const map_sock_wrkr = Lockable(IdDict())
893893
const map_del_wrkr = Lockable(Set{Int}())
894-
const _exited_callback_pid = ScopedValue{Int}()
894+
const _exited_callback_pid = ScopedValue{Int}(-1)
895895
const map_pid_statuses = Lockable(Dict{Int, Any}())
896896
const worker_starting_callbacks = Dict{Any, Base.Callable}()
897897
const worker_started_callbacks = Dict{Any, Base.Callable}()
@@ -1323,7 +1323,7 @@ function getstatus(mod::Module, pid::Int=myid())
13231323
# During the worker-exited callbacks this function may be called, at which
13241324
# point it will not exist in procs(). Thus we check whether the function is
13251325
# being called for an exited worker and allow it if so.
1326-
if pid procs() && !(isassigned(_exited_callback_pid) && _exited_callback_pid[] == pid)
1326+
if pid procs() && _exited_callback_pid[] != pid
13271327
throw(ArgumentError("Worker $(pid) does not exist, cannot get its status"))
13281328
end
13291329

test/distributed_exec.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,9 @@ end
18261826
let julia = `$(Base.julia_cmd()) --startup-file=no`; mktempdir() do tmp
18271827
pkg_project = joinpath(Base.pkgdir(DistributedNext), "Project.toml")
18281828
project = mkdir(joinpath(tmp, "project"))
1829-
depots = [mkdir(joinpath(tmp, "depot1")), mkdir(joinpath(tmp, "depot2"))]
1829+
# Keep the writable depot in the depots list so that external
1830+
# dependencies (i.e. ScopedValues.jl) can be loaded.
1831+
depots = [mkdir(joinpath(tmp, "depot1")), mkdir(joinpath(tmp, "depot2")), Base.DEPOT_PATH[1]]
18301832
load_path = [mkdir(joinpath(tmp, "load_path")), "@stdlib", "@", pkg_project]
18311833
pathsep = Sys.iswindows() ? ";" : ":"
18321834
env = Dict(
@@ -1935,15 +1937,15 @@ end
19351937
project = mktempdir()
19361938
env = Dict(
19371939
"JULIA_LOAD_PATH" => string(LOAD_PATH[1], $(repr(pathsep)), "@stdlib", $(repr(pathsep)), "$(escaped_pkg_project)"),
1938-
"JULIA_DEPOT_PATH" => DEPOT_PATH[1],
1940+
"JULIA_DEPOT_PATH" => DEPOT_PATH[end],
19391941
"TMPDIR" => ENV["TMPDIR"],
19401942
)
19411943
addprocs(1; env = env, exeflags = `--project=\$(project)`)
19421944
env["JULIA_PROJECT"] = project
19431945
addprocs(1; env = env)
19441946
""" * funcscode * """
19451947
for w in workers()
1946-
@test remotecall_fetch(depot_path, w) == [DEPOT_PATH[1]]
1948+
@test remotecall_fetch(depot_path, w) == [DEPOT_PATH[end]]
19471949
@test remotecall_fetch(load_path, w) == [LOAD_PATH[1], "@stdlib", "$(escaped_pkg_project)"]
19481950
@test remotecall_fetch(active_project, w) == project
19491951
@test remotecall_fetch(Base.active_project, w) == joinpath(project, "Project.toml")

0 commit comments

Comments
 (0)