This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-08
Channels
- # announcements (40)
- # babashka (14)
- # babashka-sci-dev (7)
- # beginners (50)
- # calva (8)
- # cider (25)
- # clj-kondo (7)
- # cljdoc (8)
- # cljs-dev (14)
- # clojars (6)
- # clojure (56)
- # clojure-australia (1)
- # clojure-berlin (2)
- # clojure-dev (16)
- # clojure-europe (18)
- # clojure-nl (1)
- # clojure-norway (5)
- # clojure-uk (7)
- # clojurescript (100)
- # cursive (57)
- # data-science (9)
- # datomic (6)
- # emacs (11)
- # figwheel (2)
- # fulcro (14)
- # helix (2)
- # hyperfiddle (9)
- # introduce-yourself (1)
- # lsp (20)
- # malli (14)
- # meander (34)
- # minecraft (1)
- # missionary (8)
- # off-topic (37)
- # pedestal (4)
- # polylith (18)
- # portal (3)
- # re-frame (5)
- # ring (33)
- # shadow-cljs (32)
- # spacemacs (6)
- # vim (16)
I've run into an odd issue that I can't explain:
(ns test-ns)
(require '[missionary.core :as m])
(defn h [x] (* x x))
(h 3) ;; 9 ;; obviously, a normal function
(defn g [x] (m/sp (h x)))
(g 3) ;; #function[clojure.core/partial/fn--5857] ;; seems right, since we're returning a task
(defn f [x] (m/? (g x)))
(f 3) ;; 9 -- seems right, since we're fetching a task and waiting for its completion
(defn h' [x] (m/? (m/sp (* x x))))
(h' 3) ;; 9 -- good, appears to be a normal function
(defn g' [x] (m/sp (h' x)))
(g' 3) ;; #function[clojure.core/partial/fn--5857] ;; seems right, since that's what g returned
(defn f' [x] (m/? (g' x)))
(f' 3) ;; Throws
;; Unhandled java.lang.NullPointerException
;; Cannot invoke "clojure.lang.IFn.invoke(Object)" because the return
;; value of "clojure.lang.RT.aget(Object[], int)" is null
;;
;; impl.cljc: 60 cloroutine.impl$coroutine$fn__59703/invoke
;; Sequential.java: 50 missionary.impl.Sequential/step
;; Sequential.java: 62 missionary.impl.Sequential/<init>
;; impl.clj: 31 missionary.impl/sp
;; impl.clj: 31 missionary.impl/sp
;; impl.cljc: 65 cloroutine.impl$coroutine$fn__59703/invoke
;; core.clj: 2629 clojure.core/partial/fn
;; Fiber.java: 24 missionary.impl.Fiber$1$1$1/<init>
;; Fiber.java: 20 missionary.impl.Fiber$1$1/task
;; impl.clj: 38 missionary.impl/fiber-task
;; impl.clj: 38 missionary.impl/fiber-task
;; core.cljc: 178 missionary.core$_QMARK_/invokeStatic
;; core.cljc: 170 missionary.core$_QMARK_/invoke
;; REPL: 65 test-ns/f'
;; REPL: 65 test-ns/f'
;; REPL: 78 test-ns/eval104116
;; REPL: 78 test-ns/eval104116
;; Compiler.java: 7181 clojure.lang.Compiler/eval
;; Compiler.java: 7136 clojure.lang.Compiler/eval
;; core.clj: 3202 clojure.core/eval
;; core.clj: 3198 clojure.core/eval
;; interruptible_eval.clj: 87 nrepl.middleware.interruptible-eval/evaluate/fn/fn
;; ... cider details from here on up ...
It's not clear to me how the task returned by g'
now fails to complete, since like the task returned by g
, it's just calling a function that returns a Long.That looks like https://github.com/leonoel/missionary/issues/35 It is not supported and the error message must be improved.
Thanks, that does seem to be the same issue.
I am curious though, why you say that get-value
is a blocking function
(defn get-value []
(m/? (m/sp :internal-use-of-missionary)))
I would expect (m/? (m/sp :internal-use-of-missionary))
to be equivalent to :internal-use-of-missionary
, at least on the JVM where m/?
can execute the generated task on the given threadm/?
outside sp
blocks the thread until the task terminates, however the task implementation is free to use any other thread to perform the job
ah, so the question of whether m/?
is blocking depends on the task (not just the contents of the task)
no, it is always blocking unless the task is instantaneous
(do (println 1 (.getName (Thread/currentThread)))
(m/? (m/sp
(println 2 (.getName (Thread/currentThread)))
(m/? (m/sleep 1))
(println 3 (.getName (Thread/currentThread)))
(m/? (m/via m/cpu))
(println 4 (.getName (Thread/currentThread)))
(m/? (m/via m/blk))
(println 5 (.getName (Thread/currentThread)))))
(println 6 (.getName (Thread/currentThread))))
1 nREPL-session-a7e6ab84-8e10-4452-a036-2990815a8a62
2 nREPL-session-a7e6ab84-8e10-4452-a036-2990815a8a62
3 missionary scheduler
4 missionary cpu-3
5 missionary blk-1
6 nREPL-session-a7e6ab84-8e10-4452-a036-2990815a8a62wow, that's some interesting output. 1,2 and 6 make sense, and I guess 3 makes sense, but it's very surprising to see parts of the body being run on threads in the cpu and blk pools despite those parts of the body not being in a (m/via m/blk ...)