In my single-threaded code, exceptions stop execution and print a stack backtrace. This is less informative than I would like [1], but sometimes it provides crucial clues.
My multi-threaded code generally uses agents (just because that's the best way I've found to get something that behaves like pmap but with better multicore processor utilization [2]). By default, exceptions in agents are silent, which is a default that I've always found to be perplexing. But if I pass an :error-handler argument to agent (as in [2] below) then I can at least see the exception... but execution doesn't halt and I don't get a backtrace. That means that if I'm running in a multi-core mode (as I usually am) then the first unfortunate thing is that I have to notice the printed exception (because execution continues past it if I don't). But the even more unfortunate thing is that I then get no backtrace. In order to get a backtrace I have to re-run my whole system in single-threaded mode, and then hope that I hit the same error (since my systems almost always involve a lot of randomness). I figure it would be easy to put an exit in the :error-handler that would quit the whole program, but I don't know how I could get the stack backtrace for the triggering exception. Does anyone know how to get this? Thanks, -Lee [1] Oh, how I long to see the values of locals up the stack in these backtraces. I understand there are ways to get this but that they require particular tool chains (emacs w/ritz?); my longing is for this kind of functionality no matter how I launch my code, or at least when I launch it via "lein run". The lack of this feature is the #1 thing I miss in Clojure relative to Common Lisp. [2] Specifically, pmap won't keep all cores busy if a thread that starts later finishes earlier than one that starts earlier. Here's the code that I use instead of pmap, which assumes there's a boolean-valued var called single-thread-mode: (defn pmapall "Like pmap but: 1) coll should be finite, 2) the returned sequence will not be lazy, 3) calls to f may occur in any order, to maximize multicore processor utilization, and 4) takes only one coll so far." [f coll] (if single-thread-mode (doall (map f coll)) (let [agents (map #(agent % :error-handler (fn [agnt except] (println except))) coll)] (dorun (map #(send % f) agents)) (apply await agents) (doall (map deref agents))))) -- 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/d/optout.