On 8 Dec 2013, at 14:21, Alex Miller <a...@puredanger.com> wrote:

> If you're starting with lein repl then I would expect errors to be printed at 
> the console - that's the actual process running the code. It's also possible 
> that the thread's untaught exception handler doesn't print. I know that the 
> expectation for async go blocks is that you should catch and handle any 
> error. Have tried catching Throwable in your thread block and printing?

Yup - that works fine (see below).

The implication, I guess, is that nrepl doesn't set the default uncaught 
exception handler? I find that surprising?

user=> (require '[clojure.core.async :refer [thread <!!]])
nil
user=> (defn thread-add [x y]
  #_=>   (thread
  #_=>     (try
  #_=>       (if (zero? y)
  #_=>         x
  #_=>         (let [t (thread-add (inc x) (dec y))]
  #_=>           (<!! t)))
  #_=>       (catch Throwable e (println e)))))
#'user/thread-add
user=> (<!! (thread-add 10 10))
20
user=> (<!! (thread-add 10 2000))
Exception in thread "async-thread-macro-1986" java.lang.OutOfMemoryError: 
unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:691)
        at 
java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:943)
        at 
java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:992)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)

--
paul.butcher->msgCount++

Silverstone, Brands Hatch, Donington Park...
Who says I have a one track mind?

http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
Skype: paulrabutcher




On 8 Dec 2013, at 14:21, Alex Miller <a...@puredanger.com> wrote:

> If you're starting with lein repl then I would expect errors to be printed at 
> the console - that's the actual process running the code. It's also possible 
> that the thread's untaught exception handler doesn't print. I know that the 
> expectation for async go blocks is that you should catch and handle any 
> error. Have tried catching Throwable in your thread block and printing?
> 
> -- 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to