132
132
testf (id_me)
133
133
testf (id_other)
134
134
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
+
135
147
# Distributed GC tests for Futures
136
148
function test_futures_dgc (id)
137
149
f = remotecall (myid, id)
@@ -143,8 +155,7 @@ function test_futures_dgc(id)
143
155
@test fetch (f) == id
144
156
@test f. v != = nothing
145
157
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))
148
159
149
160
# if unfetched, it should be deleted after a finalize
150
161
f = remotecall (myid, id)
@@ -153,7 +164,7 @@ function test_futures_dgc(id)
153
164
@test f. v === nothing
154
165
finalize (f)
155
166
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))
157
168
end
158
169
159
170
test_futures_dgc (id_me)
@@ -243,7 +254,7 @@ function test_remoteref_dgc(id)
243
254
@test remotecall_fetch (k-> (yield ();haskey (Distributed. PGRP. refs, k)), id, rrid) == true
244
255
finalize (rr)
245
256
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))
247
258
end
248
259
test_remoteref_dgc (id_me)
249
260
test_remoteref_dgc (id_other)
0 commit comments