-
Notifications
You must be signed in to change notification settings - Fork 37
Closed
Description
Ran into world age issue in registered subscription handler when using an anonymous function. Below is a reproducer using the same flow as in the test code, but triggering invocation of the anonymous function.
julia> using Test
julia> using Redis
julia> conn = RedisConnection() # host=127.0.0.1, port=6379, db=0, no password
RedisConnection("127.0.0.1", 6379, "", 0, Sockets.TCPSocket(RawFD(20) open, 0 bytes waiting))
julia> function handleException(ex)
io = IOBuffer()
showerror(io, ex, catch_backtrace())
err = String(take!(io))
@warn "Error while processing subscription: $err"
return nothing
end
handleException (generic function with 1 method)
julia> x = Any[]
Any[]
julia> function f(y::AbstractString)
push!(x, y)
end
f (generic function with 1 method)
julia> subs = open_subscription(conn, handleException) #handleException is called when an exception occurs
SubscriptionConnection("127.0.0.1", 6379, "", 0, Dict{AbstractString, Function}(), Dict{AbstractString, Function}(), Sockets.TCPSocket(RawFD(21) active, 0 bytes waiting))
julia> subscribe_data(subs, "channel", f)
32
julia> subscribe(subs, "duplicate", y->f(y.message))
34
julia> @test publish(conn, "channel", "hello, world!") > 0 #Number of connected clients returned
Test Passed
julia> @test publish(conn, "channel", "Okay, bye!") > 0 #Number of connected clients returned
Test Passed
julia> @test publish(conn, "duplicate", "hello world 2") > 0 #Number of connected clients returned
Test Passed
julia> sleep(2)
┌ Warning: Error while processing subscription: MethodError: no method matching (::var"#3#4")(::Redis.SubscriptionMessage)
│ The applicable method may be too new: running in world age 33479, while current world is 33480.
│
│ Closest candidates are:
│ (::var"#3#4")(::Any) (method too new to be called from this world context.)
│ @ Main REPL[9]:1
│
│ Stacktrace:
│ [1] subscription_loop(conn::SubscriptionConnection, err_callback::typeof(handleException))
│ @ Redis ~/.julia/dev/Redis/src/client.jl:169
│ [2] (::Redis.var"#13#14"{typeof(handleException), SubscriptionConnection})()
│ @ Redis ./threadingconstructs.jl:416
└ @ Main REPL[4]:5Metadata
Metadata
Assignees
Labels
No labels