-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
missionary.Cancelled not thrown #83
Comments
Fixed! (time
(let [delays [{:id 1
:delay 1000}
{:id 2
:delay 2000}
{:id 1
:delay 500}
{:id 1
:delay 200}]]
(m/?
(->>
(m/ap
(let [[k vs] (m/?> ##Inf (m/group-by :id (m/seed delays)))
m (m/?< vs)]
(try
(m/!) ; <---- fixed
(m/?
(m/via m/blk (Thread/sleep (:delay m)) (assoc m :slept true)))
(catch missionary.Cancelled c
(println :cancelled m)
(m/amb)))))
(m/reduce
(fn [out v]
(println v)
(conj out v))
[]))))) |
Reopening as Cancelled still does not throw when run downstream from (declare put)
(def c
(let [observe-flow (m/observe (fn [!]
(defn put [x]
(! x))
#(do)))
task (->>
(m/ap
(let [[k vs] (m/?> ##Inf (m/group-by :id observe-flow))
m (m/?< vs)]
(try
(m/!) ; <---- fixed
(m/?
(m/via m/blk (Thread/sleep (:delay m)) (assoc m :slept true)))
(catch missionary.Cancelled c
(println :cancelled m)
(m/amb))
(catch Throwable t
(println :throwing-instead-of-cancelling)
(m/amb)
))))
(m/reduce
(fn [out v]
(println v)
(conj out v))
[]))
cancel (task (fn [s] (println :success s))
(fn [f] (println :fail f)))]
cancel
))
(put {:id 1
:delay 200})
=> nil
{:id 1, :delay 200, :slept true}
(do (put {:id 1
:delay 200})
(put {:id 1
:delay 500}))
:throwing-instead-of-cancelling
=> nil
{:id 1, :delay 500, :slept true} |
On cancellation, |
hmm, the issue is that various exceptions can be thrown as arbitrary sandboxed code is run by the user. Is there any other way to detect Cancellation by |
Hey can you switch to the slack for support please, this emails 22 people |
this code properly throws
Cancelled
this one does not
How can cancellation be detected in the latter case?
The text was updated successfully, but these errors were encountered: