Skip to content

Commit 93556d2

Browse files
evetionsamtkaplan
authored andcommitted
Add warning about new workers not sharing prior global state (JuliaLang#14)
Originally proposed in JuliaLang/julia#50843
1 parent 41c0106 commit 93556d2

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/cluster.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ mutable struct WorkerConfig
9292
end
9393
end
9494

95-
@enum WorkerState W_CREATED W_CONNECTED W_TERMINATING W_TERMINATED
95+
@enum WorkerState W_CREATED W_CONNECTED W_TERMINATING W_TERMINATED W_UNKNOWN_STATE
9696
mutable struct Worker
9797
id::Int
9898
msg_lock::Threads.ReentrantLock # Lock for del_msgs, add_msgs, and gcflag

src/managers.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,11 @@ Launch `np` workers on the local host using the in-built `LocalManager`.
450450
Local workers inherit the current package environment (i.e., active project,
451451
[`LOAD_PATH`](@ref), and [`DEPOT_PATH`](@ref)) from the main process.
452452
453+
!!! warning
454+
Note that workers do not run a `~/.julia/config/startup.jl` startup script, nor do they synchronize
455+
their global state (such as command-line switches, global variables, new method definitions, and loaded modules) with any
456+
of the other running processes.
457+
453458
**Keyword arguments**:
454459
- `restrict::Bool`: if `true` (default) binding is restricted to `127.0.0.1`.
455460
- `dir`, `exename`, `exeflags`, `env`, `topology`, `lazy`, `enable_threaded_blas`: same effect

src/process_messages.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ function message_handler_loop(r_stream::IO, w_stream::IO, incoming::Bool)
210210
handle_msg(msg, header, r_stream, w_stream, version)
211211
end
212212
catch e
213-
werr = worker_from_id(wpid)
214-
oldstate = werr.state
213+
oldstate = W_UNKNOWN_STATE
215214

216215
# Check again as it may have been set in a message handler but not propagated to the calling block above
217216
if wpid < 1
@@ -222,6 +221,8 @@ function message_handler_loop(r_stream::IO, w_stream::IO, incoming::Bool)
222221
println(stderr, e, CapturedException(e, catch_backtrace()))
223222
println(stderr, "Process($(myid())) - Unknown remote, closing connection.")
224223
elseif !(wpid in map_del_wrkr)
224+
werr = worker_from_id(wpid)
225+
oldstate = werr.state
225226
set_worker_state(werr, W_TERMINATED)
226227

227228
# If unhandleable error occurred talking to pid 1, exit

0 commit comments

Comments
 (0)