diff --git a/test/threads.jl b/test/threads.jl index 57d99b7..5b94736 100644 --- a/test/threads.jl +++ b/test/threads.jl @@ -29,7 +29,7 @@ isfailed(rr) = fetch_from_owner(istaskfailed, rr) ws = ts = product(1:2, 1:2) @testset "from worker $w1 to $w2 via 1" for (w1, w2) in ws @testset "from thread $w1.$t1 to $w2.$t2" for (t1, t2) in ts - # We want (the default) lazyness, so that we wait for `Worker.c_state`! + # We want (the default) laziness, so that we wait for `Worker.c_state`! procs_added = addprocs(2; exeflags, lazy=true) @everywhere procs_added using Base.Threads @@ -44,11 +44,12 @@ isfailed(rr) = fetch_from_owner(istaskfailed, rr) take!(chan) end - # Wait on the spawned tasks on the owner - @sync begin - Threads.@spawn fetch_from_owner(wait, recv) - Threads.@spawn fetch_from_owner(wait, send) - end + # Wait on the spawned tasks on the owner. Note that we use + # timedwait() instead of @sync to avoid deadlocks. + t1 = Threads.@spawn fetch_from_owner(wait, recv) + t2 = Threads.@spawn fetch_from_owner(wait, send) + @test timedwait(() -> istaskdone(t1), 5) == :ok + @test timedwait(() -> istaskdone(t2), 5) == :ok # Check the tasks @test isdone(send)