public
Created

Lieningen breaks clojure.java.shell/sh function

  • Download Gist
README.md
Markdown

(using .. in gist file names instead of /)

With this project setup and running

lein run

I get the error

Copying 1 file to /home/sharat/labs/experiments/clojure/thread-sh/lib
Exception in thread "Thread-0" java.lang.RuntimeException: java.util.concurrent.RejectedExecutionException
        at clojure.lang.AFn.run(AFn.java:28)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.util.concurrent.RejectedExecutionException
        at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1768)
        at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:767)
        at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:658)
        at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:92)
        at clojure.core$future_call.invoke(core.clj:5406)
        at clojure.java.shell$sh.doInvoke(shell.clj:127)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at thread_sh.core$show_cmd.invoke(core.clj:6)
        at clojure.lang.AFn.run(AFn.java:24)
        ... 1 more

But, running a single .clj file with the same function call, it works just fine in both the cases, i.e., with and without starting a new thread.

project.clj
Clojure
1 2 3 4
(defproject thread-sh "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.2.1"]]
:main thread-sh.core)
src..thread-sh..core.clj
Clojure
1 2 3 4 5 6 7 8 9 10 11 12 13
(ns thread-sh.core
(:require [clojure.java.shell :as shell]))
 
(defn show-cmd
[]
(-> (shell/sh "ls")
:out
println))
 
(defn -main
[]
; calling it directly like `(show-cmd)` works fine
(.start (Thread. show-cmd)))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.