You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to update dataframe from background task
using DataFrames, Observables, Interact, Mux, Plots, WebIO
obs = Observables.Observable{DataFrame}(DataFrames.DataFrame(x =2:3, y =1:2))
on(obs) do o
println("On get data")
endschedule(
Task(
function ()
println("Waiting for data")
sleep(60)
println("Ready!")
obs[] = DataFrames.DataFrame(x =2:4, y =1:3)
end
)
)
println("Launched getting data")
functioncreateLayout(req)
println(req)
plt = Interact.@mapplot((&obs).x ,(&obs).y, label="Model output")
wdg =Widget(["df"=> obs])
@layout! wdg vbox(plt)
endfunctionserveLayout(port::Int)
tryfetch(WebIO.webio_serve(Mux.page("/", createLayout), port))
catch e
ifisa(e, IOError)
# sleep and then try againsleep(0.1)
serveLayout(port)
elsethrow(e)
endendendprintln("Starting server")
serveLayout(8080)
If I open page before Ready! I will see plot 2:3, 1:2 and when background task finishes I get error:
$ julia 1.jl
Launched getting data
Starting server
Waiting for data
Dict{Any,Any}(:query => "",:method => "GET",:params => Dict{Any,Any}(),:path => SubString{String}[],:cookies => HTTP.Cookies.Cookie[],:uri => HTTP.URI("/"),:data => UInt8[],:headers => Pair{SubString{String},SubString{String}}["Host" => "localhost:8080", "User-Agent" => "...", "Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language" => "ru,en-US;q=0.7,en;q=0.3", "Accept-Encoding" => "gzip, deflate", "Connection" => "keep-alive", "Upgrade-Insecure-Requests" => "1"])
Ready!
On get data
MethodError: no method matching (::var"#7#9")(::DataFrame)
The applicable method may be too new: running in world age 26857, while current world is 26861.
Closest candidates are:
#7(::Any) at none:0 (method too new to be called from this world context.)
Stacktrace:
[1] (::Observables.var"#16#17"{var"#7#9",Observable{Any}})(::DataFrame) at /home/olegshtch/.julia/packages/Observables/qCJWB/src/Observables.jl:152
[2] (::Observables.var"#g#15"{Observables.var"#16#17"{var"#7#9",Observable{Any}},Tuple{Observable{DataFrame}}})(::DataFrame) at /home/olegshtch/.julia/packages/Observables/qCJWB/src/Observables.jl:136
[3] #setindex!#1(::Observables.var"#2#4", ::typeof(setindex!), ::Observable{DataFrame}, ::DataFrame) at /home/olegshtch/.julia/packages/Observables/qCJWB/src/Observables.jl:87
[4] setindex!(::Observable{DataFrame}, ::DataFrame) at /home/olegshtch/.julia/packages/Observables/qCJWB/src/Observables.jl:83
[5] (::var"#5#6")() at /home/olegshtch/julia/1.jl:14
If I open page after Ready! I get plot 2:4, 1:3 without errors.
I've tried to replace
obs[] = DataFrames.DataFrame(x =2:4, y =1:3)
with
invokelatest(setindex!, obs, DataFrames.DataFrame(x =2:4, y =1:3))
but in this case listeners aren't called and plot doesn't changed.
I'm trying to update dataframe from background task
If I open page before
Ready!
I will see plot2:3, 1:2
and when background task finishes I get error:If I open page after
Ready!
I get plot2:4, 1:3
without errors.I've tried to replace
with
but in this case listeners aren't called and plot doesn't changed.
Julia 1.3.1
The text was updated successfully, but these errors were encountered: