Clojure sh stuck

I am trying to use sh from clojure.java.shell . In REPLit works fine, but with the script it gets stuck.

(ns tutorial.shell
(:use clojure.java.shell))
   (println (:out (sh "ls" )))

What should I fix?

+5
source share
1 answer

The problem is that it shuses futures and Clojure programs that use futures or agents freeze a bit before they leave when they have nothing else to do due to the way some internal mechanisms work.

To get around this, add

(shutdown-agents)

at the end of your script that ends this piece of equipment. (So ​​this is more than the name promises in that futures are also affected.)

Please note that this cannot be undone and therefore should not be used in REPL.

+7
source

All Articles