@@ -475,7 +475,7 @@ function addprocs_locked(manager::ClusterManager; kwargs...)
475475
476476 # References to launched workers, filled when each worker is fully initialized and
477477 # has connected to all nodes.
478- launched_q = Int[] # Asynchronously filled by the launch method
478+ launched_q = Base . Lockable ( Int[]) # Asynchronously filled by the launch method
479479
480480 # The `launch` method should add an object of type WorkerConfig for every
481481 # worker launched. It provides information required on how to connect
@@ -522,7 +522,7 @@ function addprocs_locked(manager::ClusterManager; kwargs...)
522522 remote_do (set_valid_processes, pid, all_w)
523523 end
524524
525- sort! (launched_q)
525+ sort! (@lock launched_q launched_q[] )
526526end
527527
528528function set_valid_processes (plist:: Array{Int} )
@@ -551,7 +551,7 @@ default_addprocs_params() = Dict{Symbol,Any}(
551551
552552function setup_launched_worker (manager, wconfig, launched_q)
553553 pid = create_worker (manager, wconfig)
554- push! (launched_q, pid)
554+ @lock launched_q push! (launched_q[] , pid)
555555
556556 # When starting workers on remote multi-core hosts, `launch` can (optionally) start only one
557557 # process on the remote machine, with a request to start additional workers of the
@@ -589,7 +589,7 @@ function launch_n_additional_processes(manager, frompid, fromconfig, cnt, launch
589589 Threads. @spawn Threads. threadpool () begin
590590 pid = create_worker (manager, wconfig)
591591 remote_do (redirect_output_from_additional_worker, frompid, pid, port)
592- push! (launched_q, pid)
592+ @lock launched_q push! (launched_q[] , pid)
593593 end
594594 end
595595 end
0 commit comments