From 868c1f458ee15c0b91451ad821b22f694825476f Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 14 Aug 2018 14:56:25 -0400 Subject: [PATCH] fix #28499, calling `cluster_cookie` before cluster starts --- stdlib/Distributed/src/cluster.jl | 3 ++- stdlib/Distributed/test/distributed_exec.jl | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/stdlib/Distributed/src/cluster.jl b/stdlib/Distributed/src/cluster.jl index 0d1614b7e972a..49df11b6eef0d 100644 --- a/stdlib/Distributed/src/cluster.jl +++ b/stdlib/Distributed/src/cluster.jl @@ -644,7 +644,7 @@ end Return the cluster cookie. """ -cluster_cookie() = LPROC.cookie +cluster_cookie() = (init_multi(); LPROC.cookie) """ cluster_cookie(cookie) -> cookie @@ -652,6 +652,7 @@ cluster_cookie() = LPROC.cookie Set the passed cookie as the cluster cookie, then returns it. """ function cluster_cookie(cookie) + init_multi() # The cookie must be an ASCII string with length <= HDR_COOKIE_LEN @assert isascii(cookie) @assert length(cookie) <= HDR_COOKIE_LEN diff --git a/stdlib/Distributed/test/distributed_exec.jl b/stdlib/Distributed/test/distributed_exec.jl index 04ef09d495a2d..f17d97697c27e 100644 --- a/stdlib/Distributed/test/distributed_exec.jl +++ b/stdlib/Distributed/test/distributed_exec.jl @@ -3,6 +3,8 @@ using Test, Distributed, Random, Serialization, Sockets import Distributed: launch, manage +@test cluster_cookie() isa String + include(joinpath(Sys.BINDIR, "..", "share", "julia", "test", "testenv.jl")) @test Distributed.extract_imports(:(begin; import Foo, Bar; let; using Baz; end; end)) ==