Reputation: 53
I try to use Cassaforte to query my cassandra db, but when i launch my code, it never end.
(defn cassandra []
(let [conn (cc/connect ["127.0.0.1", "127.0.0.2", "127.0.0.3"])
table "mytable"]
(cql/use-keyspace conn "mykeyspace")
(cql/select conn table (limit 10))))
(defn -main
"I don't do a whole lot ... yet"
[& args]
(println "Hello, World!")
(let [result (cassandra)]))
Result :
$ lein run
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Hello, World!
[the program is waiting here]
If i print the result var, it contains the rows, but same problem after.
Any idea ?
Upvotes: 4
Views: 92
Reputation: 91587
Your program is finished, you just haven't told the JVM that you explicitly want to exit at the end of main. You can do this by adding:
(System/exit 0)
to the end of your -main. Unlike a comparably small program written in just java, Clojure has started some thread pools in the background for things like agents to run on. These cause the JVM to think that some thread may still want to run and it does not immediately exit. This has been adopted as a feature by the Clojure community since then.
Upvotes: 3