This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Be sure to deref send-off futures in order to surface exceptions.

  • Loading branch information...
technomancy committed Nov 5, 2011
1 parent cb967db commit 2c6c7575f2d52a7ef6cf4da9fa875129670b2a9d
Showing with 13 additions and 13 deletions.
  1. +1 −2 project.clj
  2. +1 −2 src/die/roboter.clj
  3. +11 −9 test/die/test/roboter.clj
View
@@ -5,5 +5,4 @@
[com.mefesto/wabbitmq "0.1.4"
:exclusions [org.clojure/clojure-contrib]]
[org.clojure/tools.logging "0.2.0"]]
- :checksum-deps true
- :local-repo-classpath true)
+ :checksum-deps true)
View
@@ -101,7 +101,6 @@
(defn- success? [f timeout]
(try (.get f timeout TimeUnit/MILLISECONDS) true
- ;; TODO: get stack trace if there's an exception inside the future
(catch TimeoutException _)))
(defn- supervise [f progress timeout]
@@ -123,7 +122,7 @@
(defn- consume [{:keys [body envelope] :as msg} timeout]
(binding [*ns* context,*current-message* msg]
(log/trace "Robot received message:" (String. body))
- (run-with-timeout timeout eval (read-string (String. body))))
+ @(run-with-timeout timeout eval (read-string (String. body))))
(wabbit/ack (:delivery-tag envelope)))
(defn work
View
@@ -68,27 +68,29 @@
(is (= 1 (.get (future 1) 100 TimeUnit/MILLISECONDS)))))
(deftest test-simple-broadcast
- (with-block 1
- (let [worker (clojure.core/future
+ (let [worker (clojure.core/future
(binding [bound 1]
(work-on-broadcast)))]
(Thread/sleep 100)
- (try (broadcast `(swap! state assoc bound true))
- (finally (future-cancel worker)))))
+ (try
+ (with-block 1
+ (broadcast `(swap! state assoc bound true)))
+ (finally (future-cancel worker))))
(is (= {1 true} @state)))
(deftest test-multiple-broadcast
- (with-block 2
- (let [worker1 (clojure.core/future
+ (let [worker1 (clojure.core/future
(binding [bound 1]
(work-on-broadcast {:queue "worker1"})))
worker2 (clojure.core/future
(binding [bound 2]
(work-on-broadcast {:queue "worker2"})))]
(Thread/sleep 100)
- (try (broadcast `(swap! state assoc bound true))
- (finally (future-cancel worker1)
- (future-cancel worker2)))))
+ (try
+ (with-block 2
+ (broadcast `(swap! state assoc bound true)))
+ (finally (future-cancel worker1)
+ (future-cancel worker2))))
(is (= {1 true 2 true} @state)))
(deftest test-timeout-normal-copy

0 comments on commit 2c6c757

Please sign in to comment.