This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-03
Channels
- # aleph (2)
- # announcements (13)
- # babashka (7)
- # beginners (36)
- # calva (26)
- # cider (11)
- # circleci (13)
- # clj-kondo (15)
- # clojure (105)
- # clojure-europe (79)
- # clojure-nl (3)
- # clojure-uk (6)
- # clojurescript (17)
- # conjure (4)
- # core-logic (2)
- # cursive (10)
- # data-science (5)
- # datalevin (11)
- # datalog (14)
- # eastwood (6)
- # emacs (2)
- # figwheel-main (1)
- # fulcro (34)
- # google-cloud (1)
- # graphql (3)
- # introduce-yourself (7)
- # jobs (1)
- # leiningen (17)
- # lsp (46)
- # malli (2)
- # minecraft (3)
- # missionary (19)
- # off-topic (31)
- # other-languages (49)
- # polylith (2)
- # portal (5)
- # practicalli (1)
- # quil (77)
- # releases (1)
- # remote-jobs (1)
Thanks, I was using something like (def result (m/? some-task)) but it's better to do (def task (some-task prn prn)) and then I can cancel task in flight
i propose the special case of m/? outside of m/sp m/ap should be removed, it seems to have no value in prod code, it is JVM only, and the repl convenience use case is superseded by RCF async tests which let you work directly with async types at the REPL on any platform. It's also non-obvious and the "magic" edge case is surprising and requires explanation for new users
it also makes it too easy for a new user to throw away the cancellation callback (and not even realize it is there), that should not be the path of least resistance
Just to be clear ?
in thread mode supports cancellation via thread interruption, like any blocking call should. The problem is, no clojure repl implements evaluation interruption properly and you can observe that on any blocking call, not only ?
> it seems to have no value in prod code interop with something that expects a blocking function, e.g ring request handlers
"The problem is, no clojure repl implements evaluation interruption properly"
That's very valuable to know, if you have a safe way to use ? with a repl let us know. In the meantime I juste use (def cancel (task success failure))
If I'm understanding correctly, can the operator for "pull value out of container reference and block", if the real world use case matters, have a different name? (From this perspective the task is a reference, right?) This deref-like operation is impure, unlike m/? inside process block
I think it is well defined, I understand the potential confusion but that looks more like a teaching problem to me
IMHO missionary's learning curve is more than steep, but this is not due to the api itself, but rather to the fact that FRP is simple but not easy
I am struggling to reproduce the conclusion that the m/? abstraction is impure (other than from an internal implementation perspective). Upon further thinking I propose my statement (that m/? is pure) was ill formed: IIUC, from userland perspective, m/? is syntax (compile-time marker) and can only be considered as a unit with m/sp. At which point it is an alternative syntax for fmap and bind as per https://clojurians.slack.com/archives/CL85MBPEF/p1606665937005100
One benefit of having the same operator for threads and fibers, you can write this kind of macros once and it works in both contexts https://github.com/leonoel/missionary/blob/master/src/missionary/core.cljc#L402
I found https://github.com/riverford/objection to be useful for managing repl tasks and ensuring they get cancelled as needed:
(defn call-single
"Use for running tasks - runs it once under the name, cancels if it exists already"
[key task]
(obj/stop! key)
(obj/register
(task #(println "FINISHED" %)
#(println "ERROR" (ex-message %)))
{:stopfn (fn [c]
(c))
:aliases [key]}))
(call-single
::call
(m/sp
(try (m/? (m/sleep 1000))
(println "DONE")
(catch Exception ex
(println "EX" (ex-message ex))))))