This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-17
Channels
- # babashka (4)
- # beginners (161)
- # calva (19)
- # cider (13)
- # circleci (16)
- # clj-kondo (7)
- # cljs-dev (3)
- # cljsrn (46)
- # clojure (105)
- # clojure-australia (2)
- # clojure-nl (15)
- # clojurescript (20)
- # conjure (14)
- # core-async (8)
- # cursive (3)
- # datomic (4)
- # figwheel (5)
- # fulcro (22)
- # graalvm (1)
- # hoplon (2)
- # kaocha (3)
- # leiningen (6)
- # malli (5)
- # off-topic (19)
- # re-frame (5)
- # reagent (1)
- # reitit (43)
- # releases (1)
- # reveal (14)
- # rewrite-clj (2)
- # rum (1)
- # shadow-cljs (31)
- # spacemacs (2)
- # sql (6)
- # xtdb (8)
any idea why a thread/go-block that’s blocked/parked on a channel does not resume when we close that channel (channel closing happens after it’s already blocked/parked) e.g.
(def c (chan))
(future
(alt!!
[[c "value"]] :done))
(close! c) ;; expected alt!! to return since all its clauses are never going to succeed now
ok nevermind. understood. the expectations with writes is that someone may want to read it
and once all reads have happened the thread/goroutine will unblock
posting on a wider channel for visibility thanks @hiredman btw, do you think there are any best practices on how to gracefully shutdown a core async system? i’m hitting cases where some systems close the channels and there’s often a race condition that causes the upstream go blocks to block forever if `>!` precedes the `close!` & nobody is there to read what’s put. essentially causing a deadlock for now what i’m thinking is to use `alts!` as much as possible rather than doing any puts/gets serially via `<!` or `>!` .. this way i can have a controller channel that alts will be waiting on (along with other channels). this way I can do an early termination Other way would be to think of my systems message passing as a FSM and only allow a shutdown at a safepoint
I use this for these cases to ensure the channels are not blocking anything when they're closed
(defn drain! [ch]
(a/close! ch)
(->> (repeatedly #(a/poll! ch))
(take-while identity)
doall))
did think of this. i might as well proceed with this for now and think of a clean strategy later
posting on a wider channel for visibility thanks @hiredman btw, do you think there are any best practices on how to gracefully shutdown a core async system? i’m hitting cases where some systems close the channels and there’s often a race condition that causes the upstream go blocks to block forever if `>!` precedes the `close!` & nobody is there to read what’s put. essentially causing a deadlock for now what i’m thinking is to use `alts!` as much as possible rather than doing any puts/gets serially via `<!` or `>!` .. this way i can have a controller channel that alts will be waiting on (along with other channels). this way I can do an early termination Other way would be to think of my systems message passing as a FSM and only allow a shutdown at a safepoint