             (:fn request))))
 
 (defn async-function-with-timeout [request timeout sent-requests user-id context]
+  (swap! sent-requests inc)
+  (let [start (now)
+        response (asynchronize (:action request) (assoc context :user-id user-id))]
+    (go
+      (let [[[result end new-ctx] c] (alts! [response (async/timeout timeout)])]
+        (if (= c response)
+          [{:name (:name request)
+            :id user-id
+            :start start
+            :end end
+            :result result} new-ctx]
+          [{:name (:name request)
+            :id user-id
+            :start start
+            :end (now)
+            :result false} context])))))
+
+(defn async-function-with-timeout-old [request timeout sent-requests user-id context]
   (let [start-promise (promise)
         end-promise (promise)
         response (async/chan)

                                               :context (:context options)
                                               :simulation-start simulation-start
                                               :sent-requests sent-requests))
        responses (async/merge (map run-scenario-with-opts scenarios))
        results (async/chan)]
    (go-loop []
             (if-let [result (<! responses)]

            [clojure.core.async :as async :refer [go go-loop close! put! <!! alts! <! >!]]))

(defn- now [] (System/currentTimeMillis))

(defn asynchronize [f ctx]
  (go
    (try
      (let [result (f ctx)]
        (if (instance? clojure.core.async.impl.channels.ManyToManyChannel result)
          (let [[success? new-ctx] (<! result)]
            [success? (now) new-ctx])
          [(first result) (now) (second result)]))
      (catch Exception _
        [false (now) ctx]))))

(defn- bench [f]
  (fn [start-promise end-promise callback context]
