From fecb70da892a550361703560e68fa7938479a7f1 Mon Sep 17 00:00:00 2001 From: Julian Samaroo Date: Thu, 5 Dec 2024 06:31:17 -0600 Subject: [PATCH] Don't start watcher during precompile Otherwise precompile hangs because it's waiting on this task to finish. --- src/DistributedNext.jl | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/DistributedNext.jl b/src/DistributedNext.jl index 841269c..ca46ccf 100644 --- a/src/DistributedNext.jl +++ b/src/DistributedNext.jl @@ -132,19 +132,21 @@ include("precompile.jl") function __init__() init_parallel() - # Start a task to watch for the Distributed stdlib being loaded and - # initialized to support multiple workers. We do this by checking if the - # cluster cookie has been set, which is most likely to have been done - # through Distributed.init_multi() being called by Distributed.addprocs() or - # something. - watcher_task = Threads.@spawn while true - if _check_distributed_active() - return + if ccall(:jl_generating_output, Cint, ()) == 0 + # Start a task to watch for the Distributed stdlib being loaded and + # initialized to support multiple workers. We do this by checking if the + # cluster cookie has been set, which is most likely to have been done + # through Distributed.init_multi() being called by Distributed.addprocs() or + # something. + watcher_task = Threads.@spawn while true + if _check_distributed_active() + return + end + + sleep(1) end - - sleep(1) + errormonitor(watcher_task) end - errormonitor(watcher_task) end end