     (catch Throwable err
       err)))
 
-
-(defn reap-futures
-  []
-  (try
-    (logging/info "reaping futures")
-    (doseq [[a-future val] @future-map]
-      (when (realized? a-future)
-        (if-let [error (deref-exception a-future)]
-          (do
-            (println "************* error in future" (str a-future) error val)
-            ((:cleanup-on-error val))))
-        (swap! future-map dissoc a-future)))
-    (catch Throwable err
-      (println "error" err))))
+(let [call-counter (atom 0)]
+  (defn reap-futures
+    []
+    (swap! call-counter inc)
+    (when (zero? (rem @call-counter 240))
+      (logging/info "reaping futures" @call-counter))
+    (try
+      (doseq [[a-future val] @future-map]
+        (when (realized? a-future)
+          (if-let [error (deref-exception a-future)]
+            (do
+              (logging/error "************* error in future" (str a-future) error val)
+              ((:cleanup-on-error val))))
+          (swap! future-map dissoc a-future)))
+      (catch Throwable err
+        (logging/error "error occured in reap-futures" err)))))
 
 
 (defn map-from-routing-key-string

  ;; (convert "/home/ralf/t/seven-languages-in-seven-weeks_p4_0.pdf")


  (let [[options args banner]
        (cli/cli args
                 ["--ampqp-url" "amqp url to connect to"]
                 ["--port" "Port to listen on" :default 5000]
                 ["--root" "Root directory of web server" :default "public"])]
    (println "port:" (:port options))
    (println "root:" (:root options)))

  (periodically 250 reap-futures)


    (try
      (run-with-connection "fscrawler:test")
      (catch Exception err
        (logging/error "got exception" err)
        (trace/print-stack-trace err)
        (Thread/sleep 5000)
        (logging/info "restarting connection to rabbitmq")))))
