diff --git a/src/babashka/pods/impl.clj b/src/babashka/pods/impl.clj index 5f3df7f..7d1b7da 100644 --- a/src/babashka/pods/impl.clj +++ b/src/babashka/pods/impl.clj @@ -53,7 +53,9 @@ id (bytes->string id)] (if-let [cb (get @callbacks id)] (do (swap! callbacks dissoc id) - (cb reply)) + ;; callbacks run in their own threads to not block the + ;; processor + (future (cb reply))) (let [value* (find reply "value") value (some-> value* second @@ -237,8 +239,11 @@ (let [id (next-id) prom (promise) callback (fn [reply] - (let [[name-sym vars] (bencode->namespace pod reply)] - (callback {:name name-sym :vars vars :done prom})))] + (try (let [[name-sym vars] (bencode->namespace pod reply)] + (callback {:name name-sym :vars vars :done prom})) + (catch Throwable e + (binding [*out* *err*] + (prn e)))))] (swap! callbacks assoc id callback) (write (:stdin pod) {"op" "load-ns" diff --git a/src/babashka/pods/sci.clj b/src/babashka/pods/sci.clj index a9159e2..555ff6e 100644 --- a/src/babashka/pods/sci.clj +++ b/src/babashka/pods/sci.clj @@ -6,8 +6,6 @@ (let [env (:env ctx) ns-name name sci-ns (sci/create-ns ns-name)] - #_(swap! env assoc-in [:namespaces ns-name :obj] - sci-ns) (sci/binding [sci/ns sci-ns] (doseq [[var-name var-value] vars] (cond (ifn? var-value) @@ -15,8 +13,7 @@ (sci/new-var (symbol (str ns-name) (str var-name)) var-value)) (string? var-value) - (sci/eval-string* ctx var-value)))) - #_(prn (get-in @env [:namespaces ns-name]))) + (sci/eval-string* ctx var-value))))) (when done (deliver done :ok))) (def load-pod