Created
February 16, 2021 21:01
-
-
Save hiredman/1789849d21be38310694dbf214d60d34 to your computer and use it in GitHub Desktop.
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
(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