@alexyakushev hello! re https://github.com/alexander-yakushev/compliment/issues/123, I would try to submit a PR.
what is the best way to try my changes to compliment with my own project?
it looks like compliment is not i direct dependency of cider-nrepl
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
ok, I will see if I can come up with something. thx!
When I run tests in cider, it seems to terminate the Clojure Agent/pooledExecutor. Error in 🧵
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]]}A small reproducer would be very helpful! If you can reproduce this reliably.
I'll check
lol, ok nevermind. Totally my fault.
(defn around-tests
[tests]
(tests)
(shutdown-agents))
😄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?
I suppose this shutting down should be done by the test runner, not by the userland code.
I guess you can hack around it by checking for *repl* or whatever, but it is still a hack.
Hum, true, maybe I should cut a ticket to cognitect test runner
You can have a custom build script function that invokes cognitect.test-runner.api/test and after that calls shutdown-agents
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?
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.
Ohhhh, the main- does it. I call it with clojure -X:test
You'd need your own wrapper function that you call with -X: , and in that wrapper you can do shutdown-agents at the end.
I just switched to clojure -M:test
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
I created an issue on the test-runner github.
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.
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
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
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
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
clj only? Or you mean clojure -X as well?
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.
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)))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
I’ll take a look tomorrow