On Monday 15 December 2008 17:58, Randall R Schulz wrote: > Hi, > > I've just started using agents and as I've done that, I've noticed > that once you use an agent, exiting the REPL leads to a hang (with > zero CPU usage). As Rich pointed out to me, this is avoided by > calling (shutdown-agents). > > So my question is this: What's a simple way to ensure that > (shutdown-agents) is called when necessary without having to remember > to manually enter that call at the REPL before exiting?
This sequence of evaluations ends in the REPL hanging: 1:1 user=> (.. Runtime (getRuntime) (addShutdownHook (new Thread shutdown-agents))) nil 1:2 user=> (def agent-99 (agent "Secret agent (99)")) #'user/agent-99 1:3 user=> (send-off agent-99 (fn [a] (println (str "In agent: " a)))) In agent: Secret agent (99) #<Agent clojure.lang.ag...@5b0668> 1:4 user=> (await agent-99) nil 1:5 user=> CTRL-D [ Hangs here. CTRL-C gets back to shell prompt. ] Randall Schulz --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---