Fork me on GitHub

      (println "inside future body")
      (assert false) ;;
      (catch Exception e
        (println "error" (.getMessage e))))) ;; no error printed

  (try ;; not in a future, but just normal
    (println "inside future body")
    (assert false) ;;
    (catch Exception e
      (println "error" (.getMessage e)))) ;; error printed

      (println "inside future body")
      (throw (ex-info "throwing" {}))
      (catch Exception e
        (println "error" (.getMessage e))))) ;; error printed


user=> (assert false)
Execution error (AssertionError) at user/eval17874 (REPL:1).
Assert failed: false
user=> (instance? Exception *e)
user=> (instance? Throwable *e)


That is, assert throws AssertionError if it fails. AssertionError is not an Exception, but it is a Throwable.

👆 1

the top one doesn’t go to the catch clause


but the others do


Hi there. Is there a way to restart the agent thread pool after shutdown-agents has been called?


@rextruong technically you can set the agent executors to something custom that could support restart


Can we set the thread pool size used by future?


those methods @emccue linked can be used to customize the executors


That uses clojure.lang.Agent/soloExecutor


which is what set-agent-send-off-executor! changes


that said, there is no thread pool size for that pool - because it can do IO, you can lock up the runtime if you constrain it


Yup. That’s why I want to make the threadpool a little bit larger.


there is no thread pool size


it adds threads as needed


volatile public static ExecutorService pooledExecutor =
	Executors.newFixedThreadPool(2 + Runtime.getRuntime().availableProcessors(), 
		createThreadFactory("clojure-agent-send-pool-%d", sendThreadPoolCounter));

volatile public static ExecutorService soloExecutor = Executors.newCachedThreadPool(
	createThreadFactory("clojure-agent-send-off-pool-%d", sendOffThreadPoolCounter));


Thanks. Was checking that too.


and none of this is there in the docs of future


Takes a body of expressions and yields a future object that will
invoke the body in another thread, and will cache the result and
return it on all subsequent calls to deref/@. If the computation has
not yet finished, calls to deref/@ will block, unless the variant of
deref with timeout is used. See also - realized?.


but it is alluded to in a comment in one of the community examples


;; Note: If you leave out the call to (shutdown-agents), the program
;; will on most (all?) OS/JVM combinations "hang" for 1 minute before
;; the process exits.  It is waiting for a thread created by the
;; future call to be shut down.  shutdown-agents will shut them down
;; immediately, or (System/exit <exit-status>) will exit immediately
;; without waiting for them to shut down.


if you want to file a docstring request, please log a question at

James Carr15:03:11

What is a really good fullstack demo clojure application? Looking for something I can just clone and run docker-compose up, play around with some metric tracking that interests me on the devops side of the house


Maybe juxt/edge?

James Carr15:03:03

Looks close... was hoping to find something working with a database like postgresql that I could just run docker-compose up on


Not sure about the "really good" part - I've never seen it before. Just something I was able to find quickly.


Hey all, do you have a favorite process manager for your apps? I've got multiple Clojure/ClojureScript apps running on a single VM, and I'm trying to find a good way to wrangle them. Not only for things like automatically restarting apps on server reboot, but also for development (streaming logs for debugging, stopping the app, restarting the app, etc.) I've enjoyed using Supervisor a lot (, but I'm finding that there are logs coming out of my apps which don't end up in either the stdout or stderr logfiles. It's got such a nice CLI, but if I'm missing errors or failed ShadowCLJS compilations, then it's hurting me more than it's helping me. Anyway, any recommendations?


systemd if you're not going to go the container route


I do like systemd for automatically starting processes and stuff like that, but it would only solve part of my problem.


Is this is for a dev setup then maybe something different


What I'm trying to achieve is a unified prod/dev kind of thing. I want to develop in the same environment that my production app will run in. I've got everything in a Vagrant VM, so I've got the environment part of it figured out, but what I'd like is something that will make developing on the VM as "easy" as developing directly on my local. If I was developing on my local for example, I'd probably open up a few different terminal windows and invoke clj -M:alias or whatever the startup command is for each app. My dream VM version of that is to have a little CLI that can invoke all of the startup commands, can foreground/background the apps easily, and can still give me that same direct access to streaming logs. Supervisor can almost do all that, but logging everything from one app to one streaming output doesn't seem to be possible, at least as far as I can see.


To be honest, I'd go with Docker and Docker compose for single-machine, multi-app deployment. Your dev environment and production will always be different


What would be the benefits of Docker over Vagrant? I'm fairly comfortable in a *nix environment, but pretty new to developing on a VM. After a little research, Vagrant seemed like a good option for my goals. And I do think I've achieved that 1:1 parity between dev and prod to be honest (complete with SSL and everything). I do like the idea of hitting all of my "production problems" early on so I don't have to encounter and solve all of them in the 11th hour before I deploy, but it does seem to add a lot of complication too. I'd be curious to get your perspective though.


I've used Vagrant at multiple shops as means of standarizing dev environments, and it never looked like production (even before Docker), on top of that developer experience is not so great, especially when it comes to 'edit locally see changes in the VM', that part is always flaky. Of course you can work in the VM directly, and that (IMHO) works great if you accept some trade-offs (performance being the biggest one). Now for production, even if we're talking about a single machine - Docker simplifies this in many ways: you can test and build software locally with the same compose setup, but you get the additional benefit of not tying your application's runtime to the host, and forces you early on to figure things like secrets management, repeatable builds and so on. Sorry for the random thoughts, I'm just speaking from experience of trying to achieve dev-prod parity and never seeing it realized fully (or even in 50%)


As an alternative to Docker, it might be worth looking into podman. It's almost a drop-in replacement that doesn't require root privileges.


Any good ideas for extracting all calls to (log/warn ...) from .cljc files? I thought about simply using clojure.edn/read and then prewalk the data but it cannot be read because of #?(..) Is there some cljc aware reader? Thanks!


this might be more than you're looking for, but I think fits the bill


you can configure it to process reader conditionals


clojure.core/read-string also takes :read-cond :allow, but note that it can execute code if *read-eval* is true.


I think you can also use or clj-kondo to find var usages.


Thank you!


there's tools.reader also with .cljc support

👍 1
replied to a thread:

The eventual goal is to "chunk" the task up so that it can be paused & resumed later based on the "priority" of the task, e.g. if a high-priority task while a low-priority task is being processed, it could pause the current task, process the high-priority task, and then resume. If I already have a way of "chunking" a task up like this, is it a good idea to wrap this in an ExecutorService? Or do I need something fancier?


Are there any current libraries for SFTP? Or does it make sense to just wrap the apache commons functions for SFTP?


@jmckitrick I've been using this one for a long time and it hasn't disappointed me


I saw that, but didn't see sftp support on the home page. Guess I should dig a little deeper?


hmm, I guess you're right. sorry


Rats. I was hoping you were right.


The repo is active though so you may have luck requesting that feature. Or maybe simply hacking that .clj file


> SFTP is also supported. > My colleagues used probably this library to monitor file drops on a file server. Long time ago so don't remember if this was the same lib, but looks similar enough :)