Skip to content

Commit

Permalink
close timer on exception to put into rr_ntfy_join
Browse files Browse the repository at this point in the history
also the additional async task for timeout introduced in JuliaLang#34502 will not be required, because this PR handles that already and also differentiates between timeout and error.
  • Loading branch information
tanmaykm committed May 13, 2020
1 parent 1d06817 commit e4f1671
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions stdlib/Distributed/src/cluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -628,10 +628,15 @@ function create_worker(manager, wconfig)
timeout = worker_timeout()
Timer(1, interval=1) do timer
timeout -= 1
if timeout <= 0.0
put!(rr_ntfy_join, :TIMEDOUT)
elseif istaskdone(procmsg_task)
put!(rr_ntfy_join, :ERROR)
try
if timeout <= 0.0
put!(rr_ntfy_join, :TIMEDOUT)
elseif istaskdone(procmsg_task)
put!(rr_ntfy_join, :ERROR)
end
catch
# can happen if rr_ntfy_join is already filled
close(timer)
end
isready(rr_ntfy_join) && close(timer)
end
Expand Down Expand Up @@ -696,13 +701,7 @@ function create_worker(manager, wconfig)
send_msg_now(w, MsgHeader(RRID(0,0), ntfy_oid), join_message)

@async manage(w.manager, w.id, w.config, :register)
# wait for rr_ntfy_join with timeout
timedout = false
@async (sleep(maxwait); timedout = true; put!(rr_ntfy_join, 1))
wait(rr_ntfy_join)
if timedout
@error("worker did not connect within $maxwait seconds")
end
lock(client_refs) do
delete!(PGRP.refs, ntfy_oid)
end
Expand Down

0 comments on commit e4f1671

Please sign in to comment.