Skip to content

Commit bdadc0c

Browse files
committed
Use timedwait() in check_master_connect()
1 parent ee6e544 commit bdadc0c

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/cluster.jl

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -777,22 +777,17 @@ function redirect_output_from_additional_worker(pid, port)
777777
end
778778

779779
function check_master_connect()
780-
timeout = worker_timeout() * 1e9
781780
# If we do not have at least process 1 connect to us within timeout
782781
# we log an error and exit, unless we're running on valgrind
783782
if ccall(:jl_running_on_valgrind,Cint,()) != 0
784783
return
785784
end
786785

787786
errormonitor(
788-
@async begin
789-
start = time_ns()
790-
while !haskey(map_pid_wrkr, 1) && (time_ns() - start) < timeout
791-
sleep(1.0)
792-
end
793-
794-
if !haskey(map_pid_wrkr, 1)
795-
print(stderr, "Master process (id 1) could not connect within $(timeout/1e9) seconds.\nexiting.\n")
787+
Threads.@spawn begin
788+
timeout = worker_timeout()
789+
if timedwait(() -> !haskey(map_pid_wrkr, 1), timeout) === :timed_out
790+
print(stderr, "Master process (id 1) could not connect within $(timeout) seconds.\nexiting.\n")
796791
exit(1)
797792
end
798793
end

0 commit comments

Comments
 (0)