cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
yuhan 2021-04-05T05:26:01.145Z

How do I deal with agents without breaking Cider's connection? Running (shutdown-agents) results in this error in the terminal, and I have to restart the REPL entirely:

Exception updating the ns-cache #error {
 :cause Task clojure.lang.Agent$Action@45416446 rejected from java.util.concurrent.ThreadPoolExecutor@58b7be40[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 90]
 :via
 [{:type java.util.concurrent.RejectedExecutionException
   :message Task clojure.lang.Agent$Action@45416446 rejected from java.util.concurrent.ThreadPoolExecutor@58b7be40[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 90]
   :at [java.util.concurrent.ThreadPoolExecutor$AbortPolicy rejectedExecution ThreadPoolExecutor.java 2055]}]
 :trace
 [[java.util.concurrent.ThreadPoolExecutor$AbortPolicy rejectedExecution ThreadPoolExecutor.java 2055]
  [java.util.concurrent.ThreadPoolExecutor reject ThreadPoolExecutor.java 825]
  [java.util.concurrent.ThreadPoolExecutor execute ThreadPoolExecutor.java 1355]
  [clojure.lang.Agent$Action execute Agent.java 90]
  [clojure.lang.Agent enqueue Agent.java 268]
  [clojure.lang.Agent dispatchAction Agent.java 255]
  [clojure.lang.Agent dispatch Agent.java 241]
  [clojure.core$send_via invokeStatic core.clj 2113]
  [clojure.core$send_via doInvoke core.clj 2105]
  [clojure.lang.RestFn applyTo RestFn.java 146]
  [clojure.core$apply invokeStatic core.clj 673]
  [clojure.core$send invokeStatic core.clj 2124]
  [clojure.core$send doInvoke core.clj 2115]
  [clojure.lang.RestFn invoke RestFn.java 490]
  [cider.nrepl.middleware.track_state$make_transport$reify__5814 send track_state.clj 230]
  [nrepl.middleware.interruptible_eval$interruptible_eval$fn__994$fn__1000 invoke interruptible_eval.clj 153]
  [clojure.lang.AFn run AFn.java 22]
  [nrepl.middleware.session$session_exec$main_loop__1062 invoke session.clj 206]
  [clojure.lang.AFn run AFn.java 22]
  [java.lang.Thread run Thread.java 830]]}

dpsutton 2021-04-05T05:35:45.146Z

i don't think that's something you should call unless you are ready for the process to end. you are stopping two global executors and CIDER uses those global threadpools

yuhan 2021-04-05T05:44:35.149500Z

Hmm, I'm just learning about Agents and core.async, and tutorials mention the use of shutdown-agents to kill off running threads. I can't seem find any more fine-grained methods for doing so without affecting the entire global threadpool

dpsutton 2021-04-05T05:46:03.151Z

that's generally to kill threads in preparation of shutting down

yuhan 2021-04-05T05:46:16.151400Z

eg. if I run a (go (while true (>! ch :msg))) there's now a process running indefinitely in the background, how do I stop it?

dpsutton 2021-04-05T05:46:21.151600Z

if you need more cooperative "stop doing work" there are other means. closing channels

dpsutton 2021-04-05T05:46:55.152Z

there's lots of ways but that's not a great thing to do if you ever want to stop it

dpsutton 2021-04-05T05:47:51.153100Z

a common thing to do is make that into a loop that can recur when the puts are successful, etc

yuhan 2021-04-05T05:48:51.153600Z

Right, this is just in the context of messing around with experiments in the REPL

yuhan 2021-04-05T05:49:43.154300Z

Just wanted to make sure if this was expected behavior for Cider

dpsutton 2021-04-05T05:52:19.154800Z

yeah that would be expected. you stopped the agent executors, and then got an error that CIDER couldn't send a message to an agent

👌 1