cider

kommen 2025-03-30T16:33:45.881569Z

@alexyakushev hello! re https://github.com/alexander-yakushev/compliment/issues/123, I would try to submit a PR.

❤️ 2
kommen 2025-03-30T16:34:33.045259Z

what is the best way to try my changes to compliment with my own project?

kommen 2025-03-30T16:35:26.618029Z

it looks like compliment is not i direct dependency of cider-nrepl

oyakushev 2025-03-30T16:36:30.370279Z

That's a good question. It might be a little tricky to test your changes directly against CIDER (so that the completion immediately works differently according to your changes). I suggest testing it just by calling (compliment.core/completions "myprefix") and seeing what's returned

kommen 2025-03-30T16:53:01.193289Z

ok, I will see if I can come up with something. thx!

2025-03-30T20:05:53.832239Z

When I run tests in cider, it seems to terminate the Clojure Agent/pooledExecutor. Error in 🧵

2025-03-30T20:05:59.442859Z

Exception updating the ns-cache #error {
 :cause Task clojure.lang.Agent$Action@475e1e9e rejected from java.util.concurrent.ThreadPoolExecutor@a2db4a0[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 3]
 :via
 [{:type java.util.concurrent.RejectedExecutionException
   :message Task clojure.lang.Agent$Action@475e1e9e rejected from java.util.concurrent.ThreadPoolExecutor@a2db4a0[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 3]
   :at [java.util.concurrent.ThreadPoolExecutor$AbortPolicy rejectedExecution ThreadPoolExecutor.java 2027]}]
 :trace
 [[java.util.concurrent.ThreadPoolExecutor$AbortPolicy rejectedExecution ThreadPoolExecutor.java 2027]
  [java.util.concurrent.ThreadPoolExecutor reject ThreadPoolExecutor.java 792]
  [java.util.concurrent.ThreadPoolExecutor execute ThreadPoolExecutor.java 1328]
  [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 2126]
  [clojure.core$send_via doInvoke core.clj 2118]
  [clojure.lang.RestFn applyTo RestFn.java 146]
  [clojure.core$apply invokeStatic core.clj 673]
  [clojure.core$send invokeStatic core.clj 2137]
  [clojure.core$send doInvoke core.clj 2128]
  [clojure.lang.RestFn invoke RestFn.java 490]
  [cider.nrepl.middleware.track_state$make_transport$reify__10071 send track_state.clj 334]
  [nrepl.middleware.caught$caught_transport$reify__1414 send caught.clj 58]
  [nrepl.middleware.interruptible_eval$interruptible_eval$fn__1465$fn__1469 invoke interruptible_eval.clj 145]
  [clojure.lang.AFn run AFn.java 22]
  [nrepl.middleware.session$session_exec$session_loop__1531 invoke session.clj 245]
  [nrepl.SessionThread run SessionThread.java 21]]}

oyakushev 2025-03-30T20:07:57.361439Z

A small reproducer would be very helpful! If you can reproduce this reliably.

2025-03-30T20:08:09.843579Z

I'll check

2025-03-30T20:24:07.686559Z

lol, ok nevermind. Totally my fault.

(defn around-tests
  [tests]
  (tests)
  (shutdown-agents))
😄

➕ 2
2025-03-30T20:31:16.684119Z

Hum, it does leave me with a small issue. I call shutdown agent at the end of my tests so when they run at the command line or CI they don't wait for the pooledExecutor to close. But when I run them in cider, I don't want that behavior. Any way to gate it?

oyakushev 2025-03-30T20:32:16.626749Z

I suppose this shutting down should be done by the test runner, not by the userland code.

oyakushev 2025-03-30T20:32:49.164529Z

I guess you can hack around it by checking for *repl* or whatever, but it is still a hack.

2025-03-30T20:33:46.469659Z

Hum, true, maybe I should cut a ticket to cognitect test runner

oyakushev 2025-03-30T20:35:06.620369Z

You can have a custom build script function that invokes cognitect.test-runner.api/test and after that calls shutdown-agents

dpsutton 2025-03-30T20:35:49.512319Z

https://github.com/cognitect-labs/test-runner/blob/master/src/cognitect/test_runner.clj#L128 The runner does this for you. Why are you having to do this in your code?

2025-03-30T20:38:51.989139Z

Hum... If I don't call shutdown-agents after my tests, when I run I get: Ran 29 tests containing 238 assertions. 0 failures, 0 errors. And then a 1 minute wait before the process exits.

2025-03-30T20:39:39.324009Z

Ohhhh, the main- does it. I call it with clojure -X:test

oyakushev 2025-03-30T20:40:31.510659Z

You'd need your own wrapper function that you call with -X: , and in that wrapper you can do shutdown-agents at the end.

2025-03-30T20:49:30.662199Z

I just switched to clojure -M:test

dpsutton 2025-03-30T20:50:51.679179Z

It does seem like the api they provide for the X invocation needs the same shutdown help. I’d open an http://ask.clojure.org question about it

2025-03-30T20:51:52.976259Z

I created an issue on the test-runner github.

2025-03-30T20:52:58.671329Z

I feel -X invokation is weird in this scenario. Because the test function I think is called from other functions. So they might need a dedicated function for -X that is only meant for that.

oyakushev 2025-03-30T20:54:56.892839Z

Yes. -M controls the whole run until the exit, so it is OK to call shutdown-agents there. But with -X, you are calling a function that may be called on its own separately. Maybe you want to launch two test runs with it. So it's not really a good place to call shutdown-agents

Alex Miller (Clojure team) 2025-03-31T00:59:41.902199Z

A missing piece here is that using clj -X swaps out the agent pool with a non daemon thread agent pool so that does not prevent exit, and thus clj -X with test-runner does not need a shutdown-agents call

1
Alex Miller (Clojure team) 2025-03-31T01:01:09.964149Z

In general shutdown-agents is a destructive end-the-world action. It’s generally not something you should call in your own code in most cases (like your own test suite fixtures) that you might run at the repl

Alex Miller (Clojure team) 2025-03-31T01:02:59.591089Z

clj -X takes it a step further and makes it unnecessary to call at all. -M is clojure.main is legacy behavior so I didn’t feel comfortable changing how that worked

2025-03-31T01:28:08.028319Z

clj only? Or you mean clojure -X as well?

2025-03-31T01:29:13.047299Z

Well, in my case, it seems to still prevent the test runner from exiting, something that calling shutdown-agents in my fixture at the end, or switching to -M:test resolved.

2025-03-31T01:49:16.500939Z

clojure-agent-send-pool-9 alive= true daemon= falseDoesn't seem like running with clojure -X makes the agent send executor daemon? At least this is what prints at the end of my tests when I run them with clojure -X:test This is what I used to print:

(doseq [t (.. Thread getAllStackTraces keySet)]
    (println (.getName t) "alive=" (.isAlive t) "daemon=" (.isDaemon t)))

2025-03-31T01:58:28.706629Z

I tried updating my Clojure CLI and all my dependencies, but nope, it still looks like when I run with clojure -X the agent executor pool is still not daemon

Alex Miller (Clojure team) 2025-03-31T03:41:04.384479Z

I’ll take a look tomorrow

👍 1