Skip to content

Instantly share code, notes, and snippets.

@BenjyO238
Created July 17, 2014 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenjyO238/6aae961f81bf565cbc8a to your computer and use it in GitHub Desktop.
Save BenjyO238/6aae961f81bf565cbc8a to your computer and use it in GitHub Desktop.
(defn get-pids-for-day [fut-func f pp] ; add date rangepp
"fut-func is apply-query-to-pid, f is p-day-qry, pp partitioned-pids.
Iterate through each n pids making futures for n pids (batch size)"
(let [results []] ;vec inside vec to mirror readings/days
(for [pid-pool pp]
(let [fut (fut-func pid-pool f)]
(while (not (every? future-done? fut))
(Thread/sleep 500)
(prn (str "waiting for current future to finish..." (first pid-pool))))
(conj results (apply combine-readings (map #(identity @ %) fut)))))))
;create lazy-seq
(def test-run (get-pids-for-day apply-query-to-pid p-day-qry-mini tinyer-pid-pool))
(spit "t2t.txt" (prn test-run)) ; or
(spit "t2t.txt" (map #(println %) test-run))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment