Skip to content

Instantly share code, notes, and snippets.

@hiredman
Created February 16, 2021 21:01
Show Gist options
  • Save hiredman/1789849d21be38310694dbf214d60d34 to your computer and use it in GitHub Desktop.
Save hiredman/1789849d21be38310694dbf214d60d34 to your computer and use it in GitHub Desktop.
(do
(clojure.core.server/start-server
{:port 4567
:name "my-prepl"
:accept 'clojure.core.server/io-prepl})
(with-open [s (java.net.Socket. "localhost" 4567)
i (-> (.getInputStream s)
(java.io.InputStreamReader.)
(clojure.lang.LineNumberingPushbackReader.))
o (.getOutputStream s)]
(.write o (.getBytes "(.getId (Thread/currentThread))\n"))
(let [tid (:val (read i))
f (future
(Thread/sleep 1000)
(with-open [s (java.net.Socket. "localhost" 4567)
i (-> (.getInputStream s)
(java.io.InputStreamReader.)
(clojure.lang.LineNumberingPushbackReader.))
o (.getOutputStream s)]
(.write o (.getBytes
(prn-str
`(doseq [[t# _#] (Thread/getAllStackTraces)
:when (= (.getId t#) ~(Long/parseLong tid))]
(.stop t#)))))
(prn (read i))))]
(.write o (.getBytes "@(promise)\n"))
(read i))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment