This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-06
Channels
- # aleph (70)
- # announcements (9)
- # babashka (43)
- # babashka-sci-dev (6)
- # beginners (97)
- # cider (2)
- # clj-commons (3)
- # clj-kondo (41)
- # clojure (88)
- # clojure-europe (44)
- # clojure-nl (2)
- # clojure-spec (22)
- # clojurescript (65)
- # community-development (6)
- # conjure (10)
- # cursive (6)
- # datahike (13)
- # datomic (4)
- # eastwood (11)
- # events (1)
- # fulcro (45)
- # graalvm (1)
- # graphql (3)
- # hyperfiddle (3)
- # integrant (7)
- # jobs (1)
- # lambdaisland (1)
- # lsp (58)
- # nbb (4)
- # nrepl (3)
- # pathom (15)
- # shadow-cljs (27)
- # tools-deps (1)
Great news everyone: two pods have recently been archived in favor of bb-compatible libraries: • pod-babashka-etaoin -> https://github.com/clj-commons/etaoin • pod-babashka-aws -> https://github.com/grzm/awyeah-api
There was some babashka tooling for converting project.clj to deps.edn, which is it?
Thanks :))
I'll have a troublesome time to migrating a lein-monolith to this haha
Not sure how that works, but you can convert each subproject and then add them to the parent using local/root
yeah I was thinking on that
Using babashka/process, is there an idiomatic way to test whether the process is complete without blocking? I’ve got a case I want to read the first couple of lines of output from a long-running process and then quit without waiting for it to complete. What I’ve got right now is this (which seems to work):
(def sleeper (process/process "sleep 10"))
(def proc-future (future (.waitFor (:proc sleeper))))
(future-done? proc-future)
;; => false
;; confirming :exit hasn't been set, which of course it won't until sleeper is deref'd
(:exit sleeper)
;; => nil
;; Here's where I'd be reading from (:out sleeper), which in the real world is doing more than just sleeping
;; wait
(future-done? proc-future)
;; => true
;; as expected, :exit is still nil
(:exit sleeper)
;; => nil
;; now I get exit
(:exit @sleeper)
;; => 0
If there’s a more appropriate channel/forum for this question, please point me in that direction 🙂
The reason I want to test if it’s complete is to check if it’s errored out early: waiting for the lines takes time itself and I’d prefer not to wait.
@U0EHU1800 We have :exit-fn
now, a 1-arg function which is called upon process completion
E.g. you can fulfil a promise in that function and then block on the promise, while doing other work
I don’t think :exit-fn
would work: I explicitly don’t want to have to wait for process completion: I just want the first few lines of output.
E.g.:
$ bb -e '(babashka.process/shell {:exit-fn (fn [_] (prn :exit))} "sleep 1") nil'
:exit
Not sure if I’m helping or not… here’s what I did for https://github.com/clj-commons/etaoin/blob/00a3fe76ce3a31315401a2df57843ebeaa11c536/src/etaoin/impl/proc.clj#L59-L62
The specific example is a call to aws ecs deploy
, which will do some processing (which can take some seconds), echo the id of the deployment, and then wait for the deployment to complete, which can take 5 or more minutes. I just want to wait long enough to get the id; but if it exits earlier due to some failure, I don’t want to even wait for the id, or set some arbitrary timeout.
Ah, and here I was looking at the JDK 7 Process docs. isAlive is exactly what I was hoping was there.
This is a different API question than the other thing we discussed. It's callback functions that you can't ever change the arity of, this isn't the same for regular functions.
I have a etaoin script, using the old add-deps method. with the new system, do I need two files, the script and a bb.edn file?