                                           :decode t/read-handlers}})]
        (if (= 404 (:status md))
          (do
+           (when (zero? (mod cnt every-count-tries-emit))
+             (prn (str "Waited " cnt " times for " url)))
            (Thread/sleep wait-per-try)
-           (recur url (dec tries) md))
+           (recur url tries (inc cnt) md))
          md))
      last-result)))
 


(defn wait-for-url
  ([url]
   (wait-for-url url wait-tries nil))
  ([url tries last-result]
   (if (pos? tries)
     (let [md (client/get url
                          {:accept :transit+json
                           :as :stream


(defn wait-for-metadata-key
  ([id k]
   (wait-for-metadata-key id k wait-tries 1 nil))
  ([id k tries cnt lr]
   (if (<= cnt tries)
     (let [md (get-metadata id)]
       (if-not (get-in md [:body k])
         (do
           (when (zero? (mod cnt every-count-tries-emit))
             (prn (str "Waited " cnt " times for " k " to be metadata for " id)))
           (Thread/sleep wait-per-try)
           (recur id k tries (inc cnt) md))
         md))
     (throw (Exception. (str "Metadata key never appeared: " k ". Response: " lr))))))

