What would cause a Clojure program to not immediately exit upon finishing the last statement in the main function?
All I did was to change a (doall (map ...))<
According to the docs:
...[pmap is O]nly useful for computationally intensive functions where the time of f dominates the coordination overhead.
So this probably means there is more overhead using pmap
for your scenario than using map
. The pmap operations are probably taking a little extra time to finish up before the code after pmap
fires.
pmap
will spin up multiple threads from a threadpool to service your concurrent tasks.
Calling shutdown-agents is necessary to allow the JVM to exit in an orderly manner because the threads in the agent threadpools are not daemon threads.
You need to explicitly tell them to gracefully shutdown (but only when your program is done). This looks to have been answered before here.
Quoting from that answer:
"You need to call shutdown-agents
to kill the threads backing the threadpool used by pmap."
Docs are here: http://clojuredocs.org/clojure_core/1.3.0/clojure.core/shutdown-agents