graph lazy-compile doesn't behave lazy :)
tangrammer opened this issue · comments
Hi friends,
Today I tried to use this minimal use of plumbing.graph/lazy-compile fn
(def lg
(graph/lazy-compile
{:http-listener (fnk [system] (-> system :http-listener-listener))
:server (fnk [http-listener] (run-server (-> http-listener :h) {:port 8010}))}))
But when I invoke this graph
(def result (lg {:system system}))
I get my server running before I reference (:server result)
But theoretically this server shouldn't start in lazy-compile mode ....
Thanks in advance!
Juan
Thanks for the report. But I can't seem to replicate:
user> (def g (graph/lazy-compile {:a (fnk [x] (println "A" x) (inc x))
:b (fnk [a] (println "B" a) (* a 2))}))
#'user/g
user> (def res (g {:x 2}))
#'user/res
user> (:a res)
A 2
3
user> (:b res)
B 3
6
Can you please provide a reduced test case in this style (using printlns or other side effects to show when nodes are executed) that I can run at the REPL?
Hi Jason,
the behaviour happens when I don't use def
in the call
dev> (lg {:system system})
But I realised that makes sense due that I'm returning (and deriving => printing) the full map on the REPL
Thanks again!
Juan