@@ -208,29 +208,34 @@ put!(f, :OK)
208
208
@test remotecall_fetch (k-> haskey (Distributed. PGRP. refs, k), wid1, fid) == false
209
209
@test fetch (f) === :OK
210
210
211
- # RemoteException should be thrown on a put! when another process has set the value
212
- f = Future (wid1)
213
- fid = remoteref_id (f)
211
+ # Test this multiple times as races have been seen where `@spawn` was used over
212
+ # `@async`. Issue #124
213
+ max_attempts = 100
214
+ for i in 1 : max_attempts
215
+ let f = Future (wid1), fid = remoteref_id (f), fstore = RemoteChannel (wid2)
216
+ # RemoteException should be thrown on a put! when another process has set the value
214
217
215
- fstore = RemoteChannel (wid2)
216
- put! (fstore, f) # send f to wid2
217
- put! (f, :OK ) # set value from master
218
+ put! (fstore, f) # send f to wid2
219
+ put! (f, :OK ) # set value from master
218
220
219
- @test remotecall_fetch (k-> haskey (Distributed. PGRP. refs, k), wid1, fid) == true
221
+ @test remotecall_fetch (k-> haskey (Distributed. PGRP. refs, k), wid1, fid) == true
220
222
221
- testval = remotecall_fetch (wid2, fstore) do x
222
- try
223
- put! (fetch (x), :OK )
224
- return 0
225
- catch e
226
- if isa (e, RemoteException)
227
- return 1
228
- else
229
- return 2
223
+ testval = remotecall_fetch (wid2, fstore) do x
224
+ try
225
+ put! (fetch (x), :OK )
226
+ return 0
227
+ catch e
228
+ if isa (e, RemoteException)
229
+ return 1
230
+ else
231
+ rethrow ()
232
+ end
233
+ end
230
234
end
235
+ testval == 1 || @info " test failed on attempt $i (max $max_attempts )"
236
+ @test testval == 1
231
237
end
232
238
end
233
- @test testval == 1
234
239
235
240
# Issue number #25847
236
241
@everywhere function f25847 (ref)
0 commit comments