Created
April 12, 2012 09:37
-
-
Save yayitswei/2365902 to your computer and use it in GitHub Desktop.
what's the difference between the two?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; this one fails with | |
;;#<IllegalStateException java.lang.IllegalStateException: Invalid use of SingleClientConnManager: connection still allocated. | |
;;Make sure to release the connection before allocating another one.> | |
(defn run-test [num-requests channel-name] | |
(let [channel (ChannelAPI.) | |
requests (init-requests num-requests channel-name) | |
listener (make-listener requests)] | |
(connect-at-sim channel channel-name listener) | |
(doall (map do-request requests)))) | |
;; this one works the way I want but uses defs | |
(defn run-test2 [num-requests channel-name] | |
(def channel (ChannelAPI.)) | |
(def requests (init-requests num-requests channel-name)) | |
(def listener (make-listener requests)) | |
(connect channel channel-name listener) | |
(doall (map do-request requests))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
turns out connect-at-sim had a reference to "channel" which only worked when channel was reset in run-test2. I've corrected the typo. thanks for the help everyone :)