Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion stdlib/Distributed/test/distributed_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ end
testf(id_me)
testf(id_other)

function loop_until_false(f::Function; timeout_seconds::Integer = 60)
start_time = time_ns()
while f() != false
sleep(1)
if ( ( time_ns() - start_time )/1e9 ) > timeout_seconds
@error "Timed out" timeout_seconds
return nothing
end
end
return nothing
end

# Distributed GC tests for Futures
function test_futures_dgc(id)
f = remotecall(myid, id)
Expand All @@ -143,16 +155,17 @@ function test_futures_dgc(id)
@test fetch(f) == id
@test f.v !== nothing
yield(); # flush gc msgs
loop_until_false(() -> remotecall_fetch(k->(yield();haskey(Distributed.PGRP.refs, k)), id, fid))
@test remotecall_fetch(k->(yield();haskey(Distributed.PGRP.refs, k)), id, fid) == false


# if unfetched, it should be deleted after a finalize
f = remotecall(myid, id)
fid = remoteref_id(f)
@test remotecall_fetch(k->(yield();haskey(Distributed.PGRP.refs, k)), id, fid) == true
@test f.v === nothing
finalize(f)
yield(); # flush gc msgs
loop_until_false(() -> remotecall_fetch(k->(yield();haskey(Distributed.PGRP.refs, k)), id, fid))
@test remotecall_fetch(k->(yield();haskey(Distributed.PGRP.refs, k)), id, fid) == false
end

Expand Down Expand Up @@ -243,6 +256,7 @@ function test_remoteref_dgc(id)
@test remotecall_fetch(k->(yield();haskey(Distributed.PGRP.refs, k)), id, rrid) == true
finalize(rr)
yield(); # flush gc msgs
loop_until_false(() -> remotecall_fetch(k->(yield();haskey(Distributed.PGRP.refs, k)), id, rrid))
@test remotecall_fetch(k->(yield();haskey(Distributed.PGRP.refs, k)), id, rrid) == false
end
test_remoteref_dgc(id_me)
Expand Down