This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-02
Channels
- # adventofcode (47)
- # announcements (7)
- # aws (1)
- # babashka (52)
- # beginners (80)
- # boot (3)
- # calva (19)
- # cider (9)
- # cljs-dev (1)
- # clojure (48)
- # clojure-brasil (1)
- # clojure-dev (27)
- # clojure-europe (3)
- # clojure-madison (3)
- # clojure-nl (29)
- # clojure-spec (11)
- # clojure-sweden (1)
- # clojure-uk (49)
- # clojurescript (66)
- # core-async (20)
- # cryogen (4)
- # cursive (13)
- # data-science (7)
- # datomic (5)
- # emacs (30)
- # figwheel-main (11)
- # fulcro (15)
- # graphql (8)
- # jobs (5)
- # joker (17)
- # lambdaisland (1)
- # leiningen (2)
- # malli (2)
- # off-topic (5)
- # pathom (22)
- # re-frame (12)
- # reagent (29)
- # reitit (2)
- # ring (10)
- # shadow-cljs (57)
- # specter (3)
- # tools-deps (22)
- # vim (5)
- # xtdb (7)
With direct linking I get this:
(defn f [] 10)
(defn g [] (f))
(g) ;;=> 10
(defn f [] 11)
(g) ;;=> 10
But why does this return 11?
(def x 10)
(defn foo [] x)
(def x 11)
(foo)
11
it seems like foo is still going through the x var reference when not calling it as a function?
when a reference to a var is used as an expression direct linking does not apply @borkdude
definitionally, getting the contents of something assumes indirection through the something box
good to know. I have a clojure interpreter which directly links even var references, but maybe that's a little bit too greedy then
so when you re-def something in Clojure, (def x 10) (def x 11)
, the second time, x is still the same var object right?
user=> x
2
user=> (hash #'x)
126234454
user=> (def x 2)
#'user/x
user=> (hash #'x)
126234454
I have a unit test that gets stuck while running. I want to determine in which function it got stuck.
If I Ctrl+C
while running lein test the-ns
, the JVM succesfully quits, but no extra output is emitted or logged. I already have Thread/setDefaultUncaughtExceptionHandler
in place.
Is there a way to get a stacktrace on Ctrl+C
, so that I see what work was being done?
FWIW, Emacs offers this behavior on kill -USR2
(for Emacs itself, not clojure-wise).
I guess that a profiler could let me visualize this precise thing? Long time no use
bit of a large/complex system, with core.async abstractions and such but yes, ultimately can do!
It's possible there's special signal handling that might behave differently via Ctrl+C than interrupting programmatically. Try future and future-cancel at the top level of your test? Not quite sure of the setup you have but if your control thread is what's blocked that should help find where. If you just have a dead lock / loop in the background that won't help much since presumably you already know where control thread is stalled?
I can't reachitect the app to make all core.async usages be sync defn
calls instead... would be a lot of work
YourKit thread inspection made it easy. Sometimes one has this irrational fear of trying new tools :)
@U5RCSJ6BB I see your edited suggestion now. Interesting technique, might try the next time
@U45T93RA6 You might also be able to use set-break-handler
:
https://github.com/clojure/clojure/blob/b6835b1341e008cc69b1e6d3fa28e4362ebe16b4/src/clj/clojure/repl.clj#L280
(clojure.repl/set-break-handler! #(throw (Exception. %))) and then pressing Ctrl-C throws an exception, while not exit-ing
you can get the stack traces of all running tasks with Ctrl-\
or the equivalent, sending the USER2 signal to the vm
the jstack
program does this, based on the PID of the vm
and this is what happens when you send USER2 to emacs (emacs gives the signal to the nrepl client subprocess which knows what to do with it)
Sounds useful thanks!
I tried kill -USR2
now, it does nothing on my machine unfortunately
And jstack failed with Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach symbolicator to the process
But I'll note these down and try them in a leaner clojure process
oh - it's not USER2 that makes the stack trace print, it's QUIT, numeric code 3
What is a good way to assert some specific ex-data
in a deftest
? I would want something like thrown-with-ex-data?
.
this lib was just released, would it help? https://clojurians.slack.com/archives/C06MAR553/p1575105809280800
our exception helper lib also has something similar it's just a multimethod to extend, feel free to steal what you need. https://github.com/exoscale/ex/blob/master/modules/ex/src/clj/exoscale/ex/test.clj#L6
@U45T93RA6, OMG, recently is an understatement. Looks perfect! I'll have a go.
@U050SC7SV thanks! I'll let myself get inspired. 😍
@U0ETXRFEW Interesting, I didn't know this existed: https://clojuredocs.org/clojure.test/assert-expr
I might try to solve the assert-expr more generally some day, though. When I have eons or time. Haha.
Hi, I have a series of task that can be executed (mostly) in parallel (some depend on others). Are there any basic Clojure DAG frameworks for doing things in parallel in one JVM?
I’ve used Onyx in the past, but I think it might be too heavy for what I’m trying to achieve here.
manifold might be useful and from my limited use has been nice, https://github.com/ztellman/manifold/blob/master/docs/deferred.md#composing-with-deferreds
oh, might have misunderstood the question, probably not applicable, mb
Not a graph but have you seen https://clojure.org/reference/reducers ?