@@ -163,10 +163,10 @@ function check_worker_state(w::Worker)
163
163
else
164
164
w. ct_time = time ()
165
165
if myid () > w. id
166
- t = @async exec_conn_func (w)
166
+ t = Threads . @spawn exec_conn_func (w)
167
167
else
168
168
# route request via node 1
169
- t = @async remotecall_fetch ((p,to_id) -> remotecall_fetch (exec_conn_func, p, to_id), 1 , w. id, myid ())
169
+ t = Threads . @spawn remotecall_fetch ((p,to_id) -> remotecall_fetch (exec_conn_func, p, to_id), 1 , w. id, myid ())
170
170
end
171
171
errormonitor (t)
172
172
wait_for_conn (w)
@@ -258,7 +258,7 @@ function start_worker(out::IO, cookie::AbstractString=readline(stdin); close_std
258
258
else
259
259
sock = listen (interface, LPROC. bind_port)
260
260
end
261
- errormonitor (@async while isopen (sock)
261
+ errormonitor (Threads . @spawn while isopen (sock)
262
262
client = accept (sock)
263
263
process_messages (client, client, true )
264
264
end )
290
290
291
291
292
292
function redirect_worker_output (ident, stream)
293
- t = @async while ! eof (stream)
293
+ t = Threads . @spawn while ! eof (stream)
294
294
line = readline (stream)
295
295
if startswith (line, " From worker " )
296
296
# stdout's of "additional" workers started from an initial worker on a host are not available
@@ -329,7 +329,7 @@ function read_worker_host_port(io::IO)
329
329
leader = String[]
330
330
try
331
331
while ntries > 0
332
- readtask = @async readline (io)
332
+ readtask = Threads . @spawn readline (io)
333
333
yield ()
334
334
while ! istaskdone (readtask) && ((time_ns () - t0) < timeout)
335
335
sleep (0.05 )
@@ -430,7 +430,7 @@ if launching workers programmatically, execute `addprocs` in its own task.
430
430
431
431
```julia
432
432
# On busy clusters, call `addprocs` asynchronously
433
- t = @async addprocs(...)
433
+ t = Threads.@spawn addprocs(...)
434
434
```
435
435
436
436
```julia
@@ -496,13 +496,13 @@ function addprocs_locked(manager::ClusterManager; kwargs...)
496
496
# call manager's `launch` is a separate task. This allows the master
497
497
# process initiate the connection setup process as and when workers come
498
498
# online
499
- t_launch = @async launch (manager, params, launched, launch_ntfy)
499
+ t_launch = Threads . @spawn launch (manager, params, launched, launch_ntfy)
500
500
501
501
@sync begin
502
502
while true
503
503
if isempty (launched)
504
504
istaskdone (t_launch) && break
505
- @async begin
505
+ Threads . @spawn begin
506
506
sleep (1 )
507
507
notify (launch_ntfy)
508
508
end
@@ -512,7 +512,7 @@ function addprocs_locked(manager::ClusterManager; kwargs...)
512
512
if ! isempty (launched)
513
513
wconfig = popfirst! (launched)
514
514
let wconfig= wconfig
515
- @async setup_launched_worker (manager, wconfig, launched_q)
515
+ Threads . @spawn setup_launched_worker (manager, wconfig, launched_q)
516
516
end
517
517
end
518
518
end
@@ -592,7 +592,7 @@ function launch_n_additional_processes(manager, frompid, fromconfig, cnt, launch
592
592
wconfig. port = port
593
593
594
594
let wconfig= wconfig
595
- @async begin
595
+ Threads . @spawn begin
596
596
pid = create_worker (manager, wconfig)
597
597
remote_do (redirect_output_from_additional_worker, frompid, pid, port)
598
598
push! (launched_q, pid)
@@ -706,11 +706,11 @@ function create_worker(manager, wconfig)
706
706
join_message = JoinPGRPMsg (w. id, all_locs, PGRP. topology, enable_threaded_blas, isclusterlazy ())
707
707
send_msg_now (w, MsgHeader (RRID (0 ,0 ), ntfy_oid), join_message)
708
708
709
- errormonitor (@async manage (w. manager, w. id, w. config, :register ))
709
+ errormonitor (Threads . @spawn manage (w. manager, w. id, w. config, :register ))
710
710
# wait for rr_ntfy_join with timeout
711
711
timedout = false
712
712
errormonitor (
713
- @async begin
713
+ Threads . @spawn begin
714
714
sleep ($ timeout)
715
715
timedout = true
716
716
put! (rr_ntfy_join, 1 )
@@ -767,7 +767,7 @@ function check_master_connect()
767
767
end
768
768
769
769
errormonitor (
770
- @async begin
770
+ Threads . @spawn begin
771
771
start = time_ns ()
772
772
while ! haskey (map_pid_wrkr, 1 ) && (time_ns () - start) < timeout
773
773
sleep (1.0 )
@@ -1063,13 +1063,13 @@ function rmprocs(pids...; waitfor=typemax(Int))
1063
1063
1064
1064
pids = vcat (pids... )
1065
1065
if waitfor == 0
1066
- t = @async _rmprocs (pids, typemax (Int))
1066
+ t = Threads . @spawn _rmprocs (pids, typemax (Int))
1067
1067
yield ()
1068
1068
return t
1069
1069
else
1070
1070
_rmprocs (pids, waitfor)
1071
1071
# return a dummy task object that user code can wait on.
1072
- return @async nothing
1072
+ return Threads . @spawn nothing
1073
1073
end
1074
1074
end
1075
1075
@@ -1252,7 +1252,7 @@ function interrupt(pids::AbstractVector=workers())
1252
1252
@assert myid () == 1
1253
1253
@sync begin
1254
1254
for pid in pids
1255
- @async interrupt (pid)
1255
+ Threads . @spawn interrupt (pid)
1256
1256
end
1257
1257
end
1258
1258
end
0 commit comments