On 19 February 2010 13:35, sim <simon.cus...@gmail.com> wrote: > Yes there are other alternatives, but consider this. > > (doseq [url urls] > (let [agt (http-agent url)] > (send-off agt some-action)))
Ok I understand better where you are coming from now... you want some-action to occur after http-agent tasks have run. Which seems reasonable to me! However perhaps (some-action) should just use ::result to extract the result instead of (result) etc seeing that is really all it is happening behind the scenes? (ns foo (:require [clojure.contrib.http.agent :as a])) (def urls ["http://slashdot.org" "http://www.reddit.com"]) (defn some-action [x] (println "FOO:" (:clojure.contrib.http.agent/result x))) (doseq [url urls] (send-off (a/http-agent url) some-action)) Works as you describe for me. > I think that some-action should be able to use string and result as > the HTTP request is complete at this stage. However some-action > can't as both string and result call await without first checking if > the HTTP request is complete and you can't await in an action. > > If my understanding is correct the code above would start as many > agents as there are urls and clojure is free to distribute those > agents in whatever manner it sees fit. The only guarantee clojure > makes is that some-action will be called after all the previous > actions sent from the same thread are complete (which includes the > ones sent by http-agent itself). In other words some-action can rely > on the fact that the HTTP request has finished by the time it gets > called. > > In my case it is important to the code in some-action that http-agent > has finished as not all of the http-agent accessors return results > when the :handler is called, eg status returns NIL during the > :handler. > > I guess the real question is this, is this a bug in http-agent or an > http-agent usage error on my part? I think it is just an oversight that someone would want to use it in this way. -- 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