Skip to content

Instantly share code, notes, and snippets.

@gsimard
Created March 31, 2012 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsimard/2267395 to your computer and use it in GitHub Desktop.
Save gsimard/2267395 to your computer and use it in GitHub Desktop.
Sandbox multithread problem ?
;; Sandbox
(def ^:dynamic *sb* nil)
(defn make-sb []
(def ^:dynamic *sb* (sandbox (conj secure-tester-without-def :timeout 2000))
;; Define some functions within the sandbox
(*sb* '(defn jump [] (str "JUMP"))))
;; Swank
(def ^:dynamic *swank* nil)
(defn -startSwank []
(if (not *swank*) ;; we can't set *swank* to future, otherwise this test would block, so use a vector
(def ^:dynamic *swank* [true (future (swank.swank/start-server :host "localhost" :port 4005))]))
true)
;; Then, from emacs, I connect to swank and issue:
(*sb* '*ns*)
#<Namespace sandbox29>
(*sb* 'jump)
#<sandbox29$jump sandbox29$jump@8c666a>
(*sb* '(defn asdf [] (+ 1 2)))
#'sandbox29/asdf
(*sb* 'jump)
Unable to resolve symbol: jump in this context, compiling:(NO_SOURCE_PATH:0) [Thrown class java.util.concurrent.ExecutionException]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment