This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-02
Channels
- # 100-days-of-code (1)
- # announcements (2)
- # beginners (122)
- # boot (5)
- # calva (5)
- # cider (54)
- # cljdoc (1)
- # clojure (132)
- # clojure-brasil (1)
- # clojure-italy (4)
- # clojure-nl (6)
- # clojure-uk (105)
- # clojurescript (43)
- # core-async (17)
- # cursive (14)
- # datomic (60)
- # emacs (35)
- # figwheel-main (44)
- # fulcro (70)
- # graphql (1)
- # jobs (19)
- # jobs-discuss (5)
- # leiningen (5)
- # luminus (2)
- # off-topic (40)
- # onyx (2)
- # overtone (5)
- # re-frame (36)
- # reagent (29)
- # ring-swagger (20)
- # rum (13)
- # shadow-cljs (19)
- # testing (5)
- # tools-deps (25)
- # vim (5)
typically multiple go blocks with blocking IO or long running CPU intensive code
the go thread pool is small, and doesn't expand, and you shouldn't be putting blocking operations in it
to actually see what's stuck, the output of jstack
or Control-\ (both are ways of dumping all vm stack traces) are usually informative
I wasn't sure if @hlolli meant <!! inside go blocks or not, but yeah
ok, I believe that core.async bindings over java process builder was causing it, it was putting the stdout/stderr logs into a chan. The interface, both from https://stackoverflow.com/a/45293277/3714556 and https://github.com/rksm/subprocess suggest <!!
from outside go macro.
and I actually don't want to read the logs, just spawn a process and not being blocked.
So I homebrew something like this
(defn silent-subprocess [proc-name arg-string]
(let [ps (atom nil)]
(async/thread
(let [pbuilder (ProcessBuilder. (into-array String [proc-name arg-string]))
process (.start pbuilder)]
(reset! ps process)))
ps))
the atom so I can stop it, but it aint pretty.async/thread already doesn't block
it returns a channel that eventually has the return value
yes, so I'm going to use that, but if I'd use the original implementation
(defn run-proc-async
[proc-name arg-string callback]
(let [ch (async/chan 1000 (map callback))]
(async/thread
(let [pbuilder (ProcessBuilder. (into-array String [proc-name arg-string]))
process (.start pbuilder)]
(with-open [reader ( (.getInputStream process))]
(loop []
(when-let [line (.readLine ^java.io.BufferedReader reader)]
(async/>!! ch line)
(recur))))))
ch))
I guess it would jam if I don't take from ch
the async/thread would block if you don't read from ch, but that won't effect the go thread pool