diff --git a/backend/src/uxbox/services/queries/images.clj b/backend/src/uxbox/services/queries/images.clj index 5b337b3ae..735835322 100644 --- a/backend/src/uxbox/services/queries/images.clj +++ b/backend/src/uxbox/services/queries/images.clj @@ -39,7 +39,9 @@ [rows] (if (empty? rows) rows - (p/all (map populate-thumbnail rows)))) + (vc/blocking + (mapv (fn [row] + (images/populate-thumbnail row +thumbnail-options+)) rows)))) (defn populate-urls [row] diff --git a/backend/vendor/vertx/src/vertx/core.clj b/backend/vendor/vertx/src/vertx/core.clj index 2ce253c1a..da857f865 100644 --- a/backend/vendor/vertx/src/vertx/core.clj +++ b/backend/vendor/vertx/src/vertx/core.clj @@ -57,6 +57,30 @@ [] (Vertx/currentContext)) +(defmacro blocking + [& body] + `(let [vsm# (-> (current-context) + (vu/resolve-system)) + d# (p/deferred)] + (.executeBlocking + vsm# + (reify Handler + (handle [_ prm#] + (try + (.complete prm# (do ~@body)) + (catch Throwable e# + (.fail prm# e#))))) + true + (reify Handler + (handle [_ ar#] + (if (.failed ^AsyncResult ar#) + (p/reject! d# (.cause ^AsyncResult ar#)) + (p/resolve! d# (.result ^AsyncResult ar#)))))) + d#)) + + + + (defn wrap-blocking ([f] (wrap-blocking (current-context) f)) ([ctx f]