@@ -29,7 +29,7 @@ isfailed(rr) = fetch_from_owner(istaskfailed, rr)
29
29
ws = ts = product (1 : 2 , 1 : 2 )
30
30
@testset " from worker $w1 to $w2 via 1" for (w1, w2) in ws
31
31
@testset " from thread $w1 .$t1 to $w2 .$t2 " for (t1, t2) in ts
32
- # We want (the default) lazyness , so that we wait for `Worker.c_state`!
32
+ # We want (the default) laziness , so that we wait for `Worker.c_state`!
33
33
procs_added = addprocs (2 ; exeflags, lazy= true )
34
34
@everywhere procs_added using Base. Threads
35
35
@@ -44,11 +44,12 @@ isfailed(rr) = fetch_from_owner(istaskfailed, rr)
44
44
take! (chan)
45
45
end
46
46
47
- # Wait on the spawned tasks on the owner
48
- @sync begin
49
- Threads. @spawn fetch_from_owner (wait, recv)
50
- Threads. @spawn fetch_from_owner (wait, send)
51
- end
47
+ # Wait on the spawned tasks on the owner. Note that we use
48
+ # timedwait() instead of @sync to avoid deadlocks.
49
+ t1 = Threads. @spawn fetch_from_owner (wait, recv)
50
+ t2 = Threads. @spawn fetch_from_owner (wait, send)
51
+ @test timedwait (() -> istaskdone (t1), 5 ) == :ok
52
+ @test timedwait (() -> istaskdone (t2), 5 ) == :ok
52
53
53
54
# Check the tasks
54
55
@test isdone (send)
0 commit comments