This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-13
Channels
- # bangalore-clj (1)
- # beginners (40)
- # boot (22)
- # clara (19)
- # cljs-dev (265)
- # clojure (160)
- # clojure-dev (6)
- # clojure-italy (5)
- # clojure-russia (47)
- # clojure-spec (10)
- # clojure-uk (63)
- # clojurescript (88)
- # core-async (8)
- # cursive (54)
- # datomic (48)
- # emacs (32)
- # garden (3)
- # graphql (29)
- # hoplon (54)
- # jobs (1)
- # klipse (4)
- # luminus (5)
- # lumo (21)
- # mount (5)
- # off-topic (16)
- # om (2)
- # pedestal (10)
- # play-clj (1)
- # portkey (32)
- # re-frame (21)
- # reagent (48)
- # rum (1)
- # spacemacs (4)
- # sql (3)
- # unrepl (5)
Hi All, I've got sth I don't understand. When I define async-get-page
as follows:
(defn async-get-page [i]
(let [c (as/chan)]
(org.httpkit.client/get (format "" i)
(fn [ret]
(as/go (as/>! c i))))
(as/<!! c)))
Then the following works fine when N<8
, but completely blocks all async computations when N >= 8
:
(dotimes [i N]
(as/go (async-get-page i)))
What is going on?@joachim You're calling a blocking operation <!!
within the calling context of a go. That blocks the go thread, of which there are only 8
return the channel from async-get-page, then call <!
from within your go block
Also, (as/go (as/>! c i))
is semantically the same as (as/put! c i)
except the latter is much faster and requires less memory overhead.