This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-12
Channels
- # aleph (1)
- # aws (2)
- # babashka (44)
- # beginners (178)
- # biff (12)
- # calva (22)
- # chlorine-clover (60)
- # cider (1)
- # clj-kondo (9)
- # cljdoc (6)
- # cljs-dev (37)
- # cljss (2)
- # clojure (43)
- # clojure-europe (3)
- # clojure-finland (23)
- # clojure-italy (1)
- # clojure-nl (4)
- # clojure-norway (3)
- # clojure-spec (56)
- # clojure-uk (148)
- # clojuredesign-podcast (1)
- # clojurescript (11)
- # conjure (5)
- # core-async (22)
- # cursive (9)
- # datascript (5)
- # datomic (4)
- # duct (8)
- # emotion-cljs (2)
- # figwheel-main (15)
- # fulcro (53)
- # graalvm (68)
- # helix (2)
- # jackdaw (1)
- # kaocha (9)
- # lambdaisland (1)
- # malli (10)
- # meander (2)
- # news-and-articles (1)
- # observability (12)
- # off-topic (17)
- # pathom (1)
- # pedestal (25)
- # practicalli (1)
- # protojure (4)
- # re-frame (2)
- # reagent (57)
- # reitit (1)
- # releases (2)
- # shadow-cljs (69)
- # specter (6)
- # tools-deps (10)
- # vim (16)
- # vscode (4)
- # yada (3)
It's a little shocking to find out that timeout
will reuse the same channels. I understand why, but it's not like it's even easy to figure out that is what's being done, since printing doesn't print different timeouts distinctly or anything. It's the kind of thing that when you discover it, it's probably because it exploded in your face.
there is a ticket for this
have not gotten around to doing it
partially because I'm torn between whether it's something that should be better doc'ed or made more defensive in the code
if you close a timeout channel you close all timeout channels
that's the blowing up part :)
@alexmiller For me, the problem wasn't that it was blowing up, but I erroneously assumed they would be unique, so I built some maps based on that assumption and was terribly surprised. But if it were documented, that would have at least saved me from myself!
And because they don't print distinctly, it's not that easy to figure out what is going on.
Until I read the source code ... which is not the ideal way to understand what is happening.
It occurs to me that a dumb workaround would be:
(defn dumb-timeout
[ms]
(go
(<! (timeout ms))))
or (pipe (timeout ms) (chan) false)
that's likely less complex under the hood than a go block(?)
nope, just expands to a go-loop
@pmooser so is the issue that the (timeout) channels close “at the same time” every 10 ms?
@alexmiller what do you mean by “if you close a timeout channel you close all timeout channels” ?
(do
(clojure.core.async/go
(let [t1 (clojure.core.async/timeout 10000)]
(clojure.core.async/<! t1)
(println (str "t1::: " t1))))
(clojure.core.async/go
(let [t2 (clojure.core.async/timeout 10000)]
(clojure.core.async/close! t2)
(println (str "t2::: " t2)))))
this outputs:
(immediately)
t2::: clojure.core.async.impl.channels.ManyToManyChannel@522c88e6
(wait ~10 seconds)
t1::: clojure.core.async.impl.channels.ManyToManyChannel@8ea59ed