On Thu, Jun 24, 2010 at 6:51 AM, ka <sancha...@gmail.com> wrote: > I'm also facing the same problem - > > (let [handler (agent 50) > a (agent 42 > :error-handler > (fn [_ ex] > (do > (println "Inside agent a error handler fn" (Thread/ > currentThread)) > (send handler > (fn [_] (do (println ex (Thread/currentThread))) > 60)) > (println "Inside agent a error handler fn - after > sending to the handler agent") > (await handler) > (println "CODE DOESN'T REACH HERE ??") > (println "State of handler agent:" @handler))))] > (send a (fn [_] > (println "Inside agent a function" (Thread/ > currentThread)) > (throw (Exception. "bad news")))) > (Thread/sleep 1000) > ;(println "Errors with a:" (agent-error a)) > ;(println "Errors with handler:" (agent-error handler)) > (shutdown-agents) > (println "Errors with a:" (agent-error a)) > (println "Errors with handler:" (agent-error handler)) > (println @a) > (println @handler))
With the patch in http://www.assembla.com/spaces/clojure/tickets/390 your example will get a little further, but it has another problem. The error handler is still executed serially with agent action, as if it was itself an agent action, but you may not use 'await' inside an agent action. Using await there throws an exception, but since you're already in an error handler, that exception is silently thrown away and you still won't see the "CODE DOESN'T REACH HERE" message. If you wrap your await call in its own exception handler, you'll be able to see that's what's going on. --Chouser http://joyofclojure.com/ -- 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