Write to output before delivering result

This commit is contained in:
Michiel Borkent 2021-01-03 18:00:42 +01:00
parent 4d73312587
commit 0bffce3573

View file

@ -164,6 +164,13 @@
bytes->string) bytes->string)
err (some-> (get reply "err") err (some-> (get reply "err")
bytes->string)] bytes->string)]
;; NOTE: write to out and err before delivering promise for making
;; listening to output synchronous.
(when out
(binding [*out* out-stream]
(println out)))
(when err (binding [*out* err-stream]
(println err)))
(when (or value* error? namespace) (when (or value* error? namespace)
(cond promise? (cond promise?
(deliver chan (cond error? exception (deliver chan (cond error? exception
@ -178,12 +185,7 @@
(when promise? (when promise?
(deliver chan nil)) (deliver chan nil))
(when done-handler (when done-handler
(done-handler))) (done-handler))))
(when out
(binding [*out* out-stream]
(println out)))
(when err (binding [*out* err-stream]
(println err))))
(recur)))) (recur))))
(catch Exception e (catch Exception e
(binding [*out* *err* #_err-stream] (binding [*out* *err* #_err-stream]