132132testf (id_me)
133133testf (id_other)
134134
135+ function poll_while (f:: Function ; timeout_seconds:: Integer = 60 )
136+ start_time = time_ns ()
137+ while f ()
138+ sleep (1 )
139+ if ( ( time_ns () - start_time )/ 1e9 ) > timeout_seconds
140+ @error " Timed out" timeout_seconds
141+ return false
142+ end
143+ end
144+ return true
145+ end
146+
135147# Distributed GC tests for Futures
136148function test_futures_dgc (id)
137149 f = remotecall (myid, id)
@@ -143,8 +155,7 @@ function test_futures_dgc(id)
143155 @test fetch (f) == id
144156 @test f. v != = nothing
145157 yield (); # flush gc msgs
146- @test remotecall_fetch (k-> (yield ();haskey (Distributed. PGRP. refs, k)), id, fid) == false
147-
158+ @test poll_while (() -> remotecall_fetch (k-> (yield ();haskey (Distributed. PGRP. refs, k)), id, fid))
148159
149160 # if unfetched, it should be deleted after a finalize
150161 f = remotecall (myid, id)
@@ -153,7 +164,7 @@ function test_futures_dgc(id)
153164 @test f. v === nothing
154165 finalize (f)
155166 yield (); # flush gc msgs
156- @test remotecall_fetch (k-> (yield ();haskey (Distributed. PGRP. refs, k)), id, fid) == false
167+ @test poll_while (() -> remotecall_fetch (k-> (yield ();haskey (Distributed. PGRP. refs, k)), id, fid))
157168end
158169
159170test_futures_dgc (id_me)
@@ -243,7 +254,7 @@ function test_remoteref_dgc(id)
243254 @test remotecall_fetch (k-> (yield ();haskey (Distributed. PGRP. refs, k)), id, rrid) == true
244255 finalize (rr)
245256 yield (); # flush gc msgs
246- @test remotecall_fetch (k-> (yield ();haskey (Distributed. PGRP. refs, k)), id, rrid) == false
257+ @test poll_while (() -> remotecall_fetch (k-> (yield ();haskey (Distributed. PGRP. refs, k)), id, rrid))
247258end
248259test_remoteref_dgc (id_me)
249260test_remoteref_dgc (id_other)
0 commit comments