             [polismath.metrics :as met]
             [polismath.db :as db]
             [polismath.utils :refer :all]
+            [plumbing.core :as pc]
             [clojure.core.matrix.impl.ndarray]
             [clojure.core.async
              :as as

  (add-watch (:conv conv-actor) key f))


(defn new-conv-actor [init-fn & opts]
  (let [msgbox (chan Long/MAX_VALUE) ; we want this to be as big as possible, since backpressure doesn't really work
        conv (atom (init-fn)) ; keep track of conv state in atom so it can be dereffed

      ; In case anything happens, run the error-callback handler. Agent error handlers do not work here, since
      ; they don't give us access to the votes.
      (catch Exception e
        (error-callback votes start-time (:opts' conv) e)
        ; Wait a second before returning the origin, unmodified conv, to throttle retries
        (Thread/sleep 1000)
        conv))))
