@@ -163,10 +163,10 @@ function check_worker_state(w::Worker)
163163 else
164164 w. ct_time = time ()
165165 if myid () > w. id
166- t = Threads . @spawn Threads . threadpool () exec_conn_func (w)
166+ t = @async exec_conn_func (w)
167167 else
168168 # route request via node 1
169- t = Threads . @spawn Threads . threadpool () remotecall_fetch ((p,to_id) -> remotecall_fetch (exec_conn_func, p, to_id), 1 , w. id, myid ())
169+ t = @async remotecall_fetch ((p,to_id) -> remotecall_fetch (exec_conn_func, p, to_id), 1 , w. id, myid ())
170170 end
171171 errormonitor (t)
172172 wait_for_conn (w)
@@ -252,7 +252,7 @@ function start_worker(out::IO, cookie::AbstractString=readline(stdin); close_std
252252 else
253253 sock = listen (interface, LPROC. bind_port)
254254 end
255- errormonitor (Threads . @spawn while isopen (sock)
255+ errormonitor (@async while isopen (sock)
256256 client = accept (sock)
257257 process_messages (client, client, true )
258258 end )
284284
285285
286286function redirect_worker_output (ident, stream)
287- t = Threads . @spawn while ! eof (stream)
287+ t = @async while ! eof (stream)
288288 line = readline (stream)
289289 if startswith (line, " From worker " )
290290 # stdout's of "additional" workers started from an initial worker on a host are not available
@@ -323,7 +323,7 @@ function read_worker_host_port(io::IO)
323323 leader = String[]
324324 try
325325 while ntries > 0
326- readtask = Threads . @spawn Threads . threadpool () readline (io)
326+ readtask = @async readline (io)
327327 yield ()
328328 while ! istaskdone (readtask) && ((time_ns () - t0) < timeout)
329329 sleep (0.05 )
@@ -424,7 +424,7 @@ if launching workers programmatically, execute `addprocs` in its own task.
424424
425425```julia
426426# On busy clusters, call `addprocs` asynchronously
427- t = Threads.@spawn addprocs(...)
427+ t = @async addprocs(...)
428428```
429429
430430```julia
@@ -490,13 +490,14 @@ function addprocs_locked(manager::ClusterManager; kwargs...)
490490 # call manager's `launch` is a separate task. This allows the master
491491 # process initiate the connection setup process as and when workers come
492492 # online
493- t_launch = Threads. @spawn Threads. threadpool () launch (manager, params, launched, launch_ntfy)
493+ # NOTE: Must be `@async`. See FIXME above
494+ t_launch = @async launch (manager, params, launched, launch_ntfy)
494495
495496 @sync begin
496497 while true
497498 if isempty (launched)
498499 istaskdone (t_launch) && break
499- Threads . @spawn Threads . threadpool () begin
500+ @async begin # NOTE: Must be `@async`. See FIXME above
500501 sleep (1 )
501502 notify (launch_ntfy)
502503 end
@@ -506,7 +507,8 @@ function addprocs_locked(manager::ClusterManager; kwargs...)
506507 if ! isempty (launched)
507508 wconfig = popfirst! (launched)
508509 let wconfig= wconfig
509- Threads. @spawn Threads. threadpool () setup_launched_worker (manager, wconfig, launched_q)
510+ # NOTE: Must be `@async`. See FIXME above
511+ @async setup_launched_worker (manager, wconfig, launched_q)
510512 end
511513 end
512514 end
@@ -586,7 +588,7 @@ function launch_n_additional_processes(manager, frompid, fromconfig, cnt, launch
586588 wconfig. port = port
587589
588590 let wconfig= wconfig
589- Threads . @spawn Threads . threadpool () begin
591+ @async begin
590592 pid = create_worker (manager, wconfig)
591593 remote_do (redirect_output_from_additional_worker, frompid, pid, port)
592594 push! (launched_q, pid)
@@ -752,7 +754,7 @@ function check_master_connect()
752754 end
753755
754756 errormonitor (
755- Threads . @spawn begin
757+ @async begin
756758 timeout = worker_timeout ()
757759 if timedwait (() -> ! haskey (map_pid_wrkr, 1 ), timeout) === :timed_out
758760 print (stderr , " Master process (id 1) could not connect within $(timeout) seconds.\n exiting.\n " )
@@ -1044,13 +1046,13 @@ function rmprocs(pids...; waitfor=typemax(Int))
10441046
10451047 pids = vcat (pids... )
10461048 if waitfor == 0
1047- t = Threads . @spawn Threads . threadpool () _rmprocs (pids, typemax (Int))
1049+ t = @async _rmprocs (pids, typemax (Int))
10481050 yield ()
10491051 return t
10501052 else
10511053 _rmprocs (pids, waitfor)
10521054 # return a dummy task object that user code can wait on.
1053- return Threads . @spawn Threads . threadpool () nothing
1055+ return @async nothing
10541056 end
10551057end
10561058
@@ -1233,7 +1235,7 @@ function interrupt(pids::AbstractVector=workers())
12331235 @assert myid () == 1
12341236 @sync begin
12351237 for pid in pids
1236- Threads . @spawn Threads . threadpool () interrupt (pid)
1238+ @async interrupt (pid)
12371239 end
12381240 end
12391241end
0 commit comments