Open jwscook opened 4 years ago
This is a more accurate @spawn
version of the @threads
test
using Cassette, Base.Threads, Test
original() = false
replacement() = true
Cassette.@context Ctx
Cassette.overdub(::Ctx, fn::typeof(original), args...) = replacement(args...)
const ctx = Ctx()
function bar(testvalue)
d = Dict()
for i in 1
d[i] = Threads.@spawn original()
end
for i in keys(d)
@test fetch(d[i]) == testvalue
end
end
bar(original())
Cassette.overdub(ctx, bar, replacement())
which also fails:
julia> Cassette.overdub(ctx, bar, replacement())
Test Failed at REPL[20]:7
Expression: fetch(d[i]) == testvalue
Evaluated: false == true
ERROR: There was an error during testing
This is probably #120
I've found that
Cassette
hasn't been able to overdub into loops parallelised with@threads
. Below is my MWE, which shows how I've been using it.Interestingly it works with@spawn
, so I will be able to find a workaround by@spawn
ing andfetch
ing the iterations of my loop instead of using@threads for
.The error I get is:
Is anyone able to shed any light on this?
Version info:
Version 1.5.0-beta1.0 (2020-05-28)
7057c7e9] Cassette v0.3.3