Skip to content

Instantly share code, notes, and snippets.

@sharat87
Created August 31, 2011 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharat87/1183753 to your computer and use it in GitHub Desktop.
Save sharat87/1183753 to your computer and use it in GitHub Desktop.
Lieningen breaks clojure.java.shell/sh function

(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.

(defproject thread-sh "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.2.1"]]
:main thread-sh.core)
(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)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment