Skip to content

Commit

Permalink
Ensure that await can be used in userland
Browse files Browse the repository at this point in the history
  • Loading branch information
cemerick committed Apr 16, 2012
1 parent 9f11cfd commit bbe598f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/clojure/clojure/tools/nrepl/middleware/session.clj
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@
; TODO is this something we need to consider in general, or is this
; specific hack reasonable?
clojure.test/*test-out* out]
(atom (merge baseline-bindings (get-thread-bindings))
; nrepl.server happens to use agents for connection dispatch
; don't capture that *agent* binding for userland REPL sessions
(atom (merge baseline-bindings (dissoc (get-thread-bindings) #'*agent*))
:meta {:id id
:stdin-reader in
:stdin-writer in-writer}))))))
Expand Down
6 changes: 6 additions & 0 deletions src/test/clojure/clojure/tools/nrepl_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,9 @@
(ack/reset-ack-port!)
(with-open [s2 (server/start-server :ack-port (.getLocalPort (:ss @s)))]
(is (= (.getLocalPort (:ss @s2)) (ack/wait-for-ack 10000))))))

(def-repl-test agent-await
(is (= [42] (repl-values session (code (let [a (agent nil)]
(send a (fn [_] (Thread/sleep 1000) 42))
(await a)
@a))))))

0 comments on commit bbe598f

Please sign in to comment.