@@ -172,19 +172,25 @@ function _require_from_serialized(node::Int, mod::Symbol, path_to_try::String, t
172
172
end
173
173
restored = _include_from_serialized (content)
174
174
isa (restored, Exception) && return restored
175
- others = filter (x -> x != myid (), procs ())
176
- refs = Any[
177
- (p, @spawnat (p,
178
- let m = try
179
- _include_from_serialized (content)
180
- catch ex
181
- isa (ex, Exception) ? ex : ErrorException (string (ex))
175
+
176
+ results = sizehint! (Vector {Tuple{Int,Any}} (), nprocs ())
177
+ @sync for p in procs ()
178
+ if p != myid ()
179
+ @async begin
180
+ result = remotecall_fetch (p) do
181
+ let m = try
182
+ _include_from_serialized (content)
183
+ catch ex
184
+ isa (ex, Exception) ? ex : ErrorException (string (ex))
185
+ end
186
+ isa (m, Exception) ? m : nothing
182
187
end
183
- isa (m, Exception) ? m : nothing
184
- end ))
185
- for p in others ]
186
- for (id, ref) in refs
187
- m = fetch (ref)
188
+ end
189
+ push! (results, (p, result))
190
+ end
191
+ end
192
+ end
193
+ for (id, m) in results
188
194
if m != = nothing
189
195
warn (" Node state is inconsistent: node $id failed to load cache from $path_to_try . Got:" )
190
196
warn (m, prefix= " WARNING: " )
@@ -460,8 +466,13 @@ function _require(mod::Symbol)
460
466
eval (Main, :(Base. include_from_node1 ($ path)))
461
467
462
468
# broadcast top-level import/using from node 1 (only)
463
- refs = Any[ @spawnat p eval (Main, :(Base. include_from_node1 ($ path))) for p in filter (x -> x != 1 , procs ()) ]
464
- for r in refs; wait (r); end
469
+ @sync begin
470
+ for p in filter (x -> x != 1 , procs ())
471
+ @async remotecall_fetch (p) do
472
+ eval (Main, :(Base. include_from_node1 ($ path); nothing ))
473
+ end
474
+ end
475
+ end
465
476
else
466
477
eval (Main, :(Base. include_from_node1 ($ path)))
467
478
end
0 commit comments