This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-23
Channels
- # announcements (7)
- # babashka (40)
- # babashka-sci-dev (74)
- # beginners (74)
- # calva (31)
- # cider (11)
- # clj-kondo (22)
- # cljs-dev (1)
- # cljsrn (1)
- # clojure (70)
- # clojure-brasil (3)
- # clojure-dev (12)
- # clojure-europe (39)
- # clojure-nl (2)
- # clojure-norway (15)
- # clojure-uk (9)
- # clojurescript (69)
- # community-development (2)
- # conjure (1)
- # core-async (3)
- # cursive (1)
- # data-science (1)
- # datalevin (13)
- # datomic (17)
- # emacs (42)
- # events (1)
- # fulcro (16)
- # graphql (9)
- # helix (1)
- # holy-lambda (14)
- # honeysql (2)
- # hugsql (3)
- # hyperfiddle (5)
- # kaocha (10)
- # lsp (41)
- # luminus (5)
- # malli (7)
- # meander (3)
- # membrane (47)
- # off-topic (23)
- # podcasts (2)
- # polylith (34)
- # rdf (4)
- # re-frame (2)
- # releases (2)
- # remote-jobs (1)
- # ring (16)
- # shadow-cljs (111)
- # spacemacs (6)
- # test-check (2)
- # tools-deps (19)
you’re missing a paren in the first one
(def foo '[[a b c] [[d e] [f g]]])
(apply vector (first foo) (second foo))
or if you prefer slightly more readable:
(reduce (fn [xs x] (if (coll? (first x)) (apply conj xs x) (conj xs x))) [] foo)
(def foo '[[a b c] [[d e] [f g]] [[i j] [k l]]])
(into [(first foo)]
(mapcat identity (rest foo)))
;; => [[a b c] [d e] [f g] [i j] [k l]]
Maybe this works too?Using the clojure.core.async.pool-size
system property, see: https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/exec/threadpool.clj#L16
@U031CHTGX1T Thank you for the response
You don’t, this is not meant to be defined per call, it’s a global setting
Consider using async/pipeline
to use dedicated threads and where you can specify the parallelism
You can specify that when starting the JVM (`-D` flag I believe)
:jvm-opts ["-Dclojure.core…=X"]
But it depends where you deploy your app as well
E.g. I think you will not run it in Leiningen in prod right
Can we change the value of clojure.core.async.pool-size
at runtime? I mean I do not want to set it in project.clj or as in system property
I believe the answer to this is no. It's a jvm system property. But, also, it wouldn't be a good idea, because it could lead to unpredictable behavior. My recommendation is to go ahead and set the pool-size to a higher value (if that's really what you want to do), as pool size is something giving threads at disposal. But you should likely make sure that setting the pool size to a higher value is really what you want to do - if it will actually solve your problem. I would do a lot of experimentation first.
thanks for the response @U0G3Y3NA0, Is there any other property where we can increase or decrease threads in runtime?
https://clojurians.slack.com/archives/C053AK3F9/p1648028494396569 wanted to change number of running threads
this var is private probably for a good reason. As you can see in the docstring there are some problems you may encounter trying to change the value
by default it will be 8 right? So what we can do if we want some higher number of threads when we running below code
(->> data
(fn [] (.....transformation logic..))
(async/merge)
(async/reduce conj [])
(async/<!!))
@U01J3DB39R6 — I think async/pipeline
is what you really want.
The async “dispatch” thread pool is for go blocks only, e.g. small non-blocking things. Unless you have a machine with A LOT of cores, changing this will probably not give you much.
pipeline
and friends allow you to use dedicated threads where you can easily tune the number of parallel tasks to run.

Since you are asking for the number of threads, it seems you want to do computation expensive or even blocking operations, in this case you should not use the dispatch pool anyway
Thanks for your response @U031CHTGX1T, But I did not get what you meant by dispatch here
https://eli.thegreenplace.net/2017/clojure-concurrency-and-blocking-with-coreasync/ here is a good article explaining what is thread-pool in core async and how it is connected with blocking go blocks
Probably explained in the article @U04V4KLKC shared. “dispatch thread pool” is just the name of the fixed-size thread pool that can be adjusted with the pool size property
I would recommend https://github.com/clj-commons/claypoole if you want too customize an executor of sorts
@U031CHTGX1T I made use of https://clojure.org/about/concurrent_programming , anythoughts?
Sorry, I don’t understand your question. Thoughts on what?
Not sure where to ask this, but is there any news about https://clojuredocs.org/ ? It hasn't had any code changes since last August, there are a bunch of issues and pull requests that haven't been touched in that time, and it hasn’t updated to include any changes to core libraries (core.async for example), let alone clojure 1.11 updates.
I was wondering the same thing! 😿
@U4J1HQKFH hey there, any news?
I mean, Clojure 1.11 was just released days ago. Give them a bit of time 🙂. OK to ask, of course.
Hah that's true, but it seemed prudent to ask given that no other work has been done on the site since last year either.
is there a way to enable me to say ::foo/key
without loading the foo
namespace, I just want the key ns sugars. And maybe I can't load foo
right now
in Clojure 1.11 you can now use (:require [the.foo :as-alias foo])
pre-1.11 you could do
(create-ns 'the.foo)
(alias 'foo 'the.foo)
I’d also question if you need auto resolve keyword namespaces at all. Sometimes the answer is yes, but often the answer is :foo/key
is just as valid
I thought :foo/key
would be correct in this case? ::foo/key
is necessary when you alias/shorten a namespace into foo
I have found it is a nice catch for typos (at least in the namespace piece); also, for these java-ish long namespaces like :sicmutils.expression.simplifier/option
i been using calva as my repl development tool. I'm able to load and execute imports and funcs i have written, but unable to load the whole namespace or file. Can someone point out what im doing wrong?
groww-scraper.core=> (load-file "src/groww_scraper/core.clj")
((require (quote [clj-http.client :as client]) (quote [cheshire.core :as json]) (quote [environ.core :refer [env]]) (quote [clj-time.core :as t]) (quote [clj-time.coerce :as tc]) (quote [next.jdbc :as jdbc]) (quote [next.jdbc.types :as jdbc.types]) (quote [next.jdbc.date-time :as jdbc.date]) (quote [honey.sql :as sql]) (quote [honey.sql.helpers :as sqlh])) (:gen-class)) - failed: Extra input spec: :clojure.core.specs.alpha/ns-form
There's something wrong with the ns
form in that file. Looks like you might be using require
instead of :require
?
Also, I don't use Calva so I'm not sure, but I think you might want to use the "Load current file" command instead of load-file
:
https://calva.io/commands-top10/
It is certainly more convenient to use the Calva command for it. Then you can stay in the file. Have you found the Getting Started REPL, @U037THMHCD8? There's a command that starts it. It will open up some files for you which form a guide where you can learn Calva, some structural editing and even some Clojure. (And I now realize I should spend some more time on introducing the ns
form in that guide.)
The ns
form is indeed a bit of a beast. https://gist.github.com/ghoseb/287710/ is a pretty good cheat sheet.
Now added this to the Calva Clojure guide: https://github.com/BetterThanTomorrow/dram/commit/b7e9d11adb7c89c709fed011c7bd866ebcc6ef53
@U0ETXRFEW im able to reproduce this in the repl by calling the load
function
this is what my import looks like:
(ns groww-scraper.core
(require '[clj-http.client :as client]
'[cheshire.core :as json]
'[environ.core :refer [env]]
'[clj-time.core :as t]
'[clj-time.coerce :as tc]
'[next.jdbc :as jdbc]
'[next.jdbc.types :as jdbc.types]
'[next.jdbc.date-time :as jdbc.date]
'[honey.sql :as sql]
'[honey.sql.helpers :as sqlh])
(:gen-class))
when i switch from require
to :require
and remove the '
it worked 🎉
@U4ZDX466T @U0ETXRFEW
the NS form cheatsheet link and docs/comments on calva were very helpful.
to sum it up: with the ns
form i was never suppose to use the require
function. It was should be a dataobject, right?
nah, just 4 😉
4 out of about 600 things that can be called as functions in Cloure.core seems quite a small number
@U05254DQM I think @U036UA9LZSQ was saying that the standard library is much larger than one might expect, using “random” as in “why is this here?” I was attempting a joke by taking “random” very literally!
If it helps to see a large fraction of them broken down into categories of related functionality, check out the cheatsheet: https://clojure.org/api/cheatsheet or here https://jafingerhut.github.io/
hi, i'm building a prototype REST API for accessing and adding a collection of songs using Compojure and Datomic. i made d/db an atom and when I POST to add a song, i also update the db atom by using swap!. however, i am running into errors doing this. my question is, how is keeping the datomic cached db up to date usually done in a web application?
I’m not entirely sure I understand, but I assume you are swapping the db value with some other thing related to a POST request?
However I don’t think doing that (and maybe even holding the db in an atom) is really necessary or what you actually want?
You might just want to use d/transact
on the db value with your new data.
If you want to cache reads on top of that, you might want to run any queries first and then cache the actual view you want to present in your app. Or you can do something very simple with E-Tag or Last-Modified so the browser takes care of caching responses. Datomic should be able to help you there.