Skip to content

Commit 8fd43af

Browse files
committed
Use timedwait() in check_master_connect()
1 parent 612e3f2 commit 8fd43af

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/cluster.jl

+3-8
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,6 @@ function redirect_output_from_additional_worker(pid, port)
751751
end
752752

753753
function check_master_connect()
754-
timeout = worker_timeout() * 1e9
755754
# If we do not have at least process 1 connect to us within timeout
756755
# we log an error and exit, unless we're running on valgrind
757756
if ccall(:jl_running_on_valgrind,Cint,()) != 0
@@ -760,13 +759,9 @@ function check_master_connect()
760759

761760
errormonitor(
762761
Threads.@spawn begin
763-
start = time_ns()
764-
while !haskey(map_pid_wrkr, 1) && (time_ns() - start) < timeout
765-
sleep(1.0)
766-
end
767-
768-
if !haskey(map_pid_wrkr, 1)
769-
print(stderr, "Master process (id 1) could not connect within $(timeout/1e9) seconds.\nexiting.\n")
762+
timeout = worker_timeout()
763+
if timedwait(() -> !haskey(map_pid_wrkr, 1), timeout) === :timed_out
764+
print(stderr, "Master process (id 1) could not connect within $(timeout) seconds.\nexiting.\n")
770765
exit(1)
771766
end
772767
end

0 commit comments

Comments
 (0)