Discussion:
Issue with alt (and timeout, let-flow, recur, deferred)
Alf Kristian Støyle
2017-08-27 06:44:24 UTC
Permalink
Hi! I couldn't find a specific manifold mailing list, using aleph, hope
that's ok.

I am probably doing something incorrectly, but I am having a hard time
seeing what. And if not, there may be an issue with alt.

I am making a process which will run periodically, but it should also be
possible to kill it. This is the code:

(defn foo [kill-d]
(d/loop []
(prn "Setting up with timeout" 1000)
(d/let-flow [res (d/alt kill-d (d/timeout! (d/deferred) 1000 :ok))]
(prn "Got a result" res)
(if (= res :ok)
(d/recur)
(prn "Got a kill message for token, not recurring")))))



When running the alt does not trigger on the timeout.

(def kill (d/deferred))
=> #'user/kill
(foo kill)
"Setting up with timeout" 1000
=> << 
 >>
;; Witing a bit...

(d/success! kill 1)
"Got a result" 1
"Got a kill message for token, not recurring"

Modifying the code, removing the kill-d from the alt, now it works, except
there is no way of killing it;

(defn foo [kill-d]
(d/loop []
(prn "Setting up with timeout" 1000)
(d/let-flow [res (d/alt (d/timeout! (d/deferred) 1000 :ok))]
(prn "Got a result" res)
(if (= res :ok)
(d/recur)
(prn "Got a kill message for token, not recurring")))))




(def kill (d/deferred)) ; Not really necessary...
=> #'user/kill
(foo kill)
"Setting up with timeout" 1000
=> << 
 >>
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000


Anyone have a clue on what's going on here? I've experienced a bit with alt
in other contexts, and it seem to be working just fine. So I am a bit
baffled...

Cheers,
Alf
--
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aleph-lib+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
ztellman
2017-09-11 22:34:33 UTC
Permalink
Hi, sorry for the late reply to this. Can you file an issue on the
Manifold project? The `alt` method was added by someone else, I'll need to
look at it a bit to understand what might be going on here, and it would be
good to have an issue to track this.

On Saturday, August 26, 2017 at 11:44:24 PM UTC-7, Alf Kristian StÞyle
Post by Alf Kristian Støyle
Hi! I couldn't find a specific manifold mailing list, using aleph, hope
that's ok.
I am probably doing something incorrectly, but I am having a hard time
seeing what. And if not, there may be an issue with alt.
I am making a process which will run periodically, but it should also be
(defn foo [kill-d]
(d/loop []
(prn "Setting up with timeout" 1000)
(d/let-flow [res (d/alt kill-d (d/timeout! (d/deferred) 1000 :ok))]
(prn "Got a result" res)
(if (= res :ok)
(d/recur)
(prn "Got a kill message for token, not recurring")))))
When running the alt does not trigger on the timeout.
(def kill (d/deferred))
=> #'user/kill
(foo kill)
"Setting up with timeout" 1000
=> << 
 >>
;; Witing a bit...
(d/success! kill 1)
"Got a result" 1
"Got a kill message for token, not recurring"
Modifying the code, removing the kill-d from the alt, now it works, except
there is no way of killing it;
(defn foo [kill-d]
(d/loop []
(prn "Setting up with timeout" 1000)
(d/let-flow [res (d/alt (d/timeout! (d/deferred) 1000 :ok))]
(prn "Got a result" res)
(if (= res :ok)
(d/recur)
(prn "Got a kill message for token, not recurring")))))
(def kill (d/deferred)) ; Not really necessary...
=> #'user/kill
(foo kill)
"Setting up with timeout" 1000
=> << 
 >>
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
Anyone have a clue on what's going on here? I've experienced a bit with
alt in other contexts, and it seem to be working just fine. So I am a bit
baffled...
Cheers,
Alf
--
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aleph-lib+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alf Kristian Støyle
2017-09-13 05:56:41 UTC
Permalink
Done!

I thinks the issue is more general than with just timeout. Updated the
explanation a bit in the issue.
https://github.com/ztellman/manifold/issues/141

I think this is way over my head, but I may try to have a look to
understand what is going on.

Cheers,
Alf
Post by ztellman
Hi, sorry for the late reply to this. Can you file an issue on the
Manifold project? The `alt` method was added by someone else, I'll need to
look at it a bit to understand what might be going on here, and it would be
good to have an issue to track this.
On Saturday, August 26, 2017 at 11:44:24 PM UTC-7, Alf Kristian StÞyle
Post by Alf Kristian Støyle
Hi! I couldn't find a specific manifold mailing list, using aleph, hope
that's ok.
I am probably doing something incorrectly, but I am having a hard time
seeing what. And if not, there may be an issue with alt.
I am making a process which will run periodically, but it should also be
(defn foo [kill-d]
(d/loop []
(prn "Setting up with timeout" 1000)
(d/let-flow [res (d/alt kill-d (d/timeout! (d/deferred) 1000 :ok))]
(prn "Got a result" res)
(if (= res :ok)
(d/recur)
(prn "Got a kill message for token, not recurring")))))
When running the alt does not trigger on the timeout.
(def kill (d/deferred))
=> #'user/kill
(foo kill)
"Setting up with timeout" 1000
=> << 
 >>
;; Witing a bit...
(d/success! kill 1)
"Got a result" 1
"Got a kill message for token, not recurring"
Modifying the code, removing the kill-d from the alt, now it works,
except there is no way of killing it;
(defn foo [kill-d]
(d/loop []
(prn "Setting up with timeout" 1000)
(d/let-flow [res (d/alt (d/timeout! (d/deferred) 1000 :ok))]
(prn "Got a result" res)
(if (= res :ok)
(d/recur)
(prn "Got a kill message for token, not recurring")))))
(def kill (d/deferred)) ; Not really necessary...
=> #'user/kill
(foo kill)
"Setting up with timeout" 1000
=> << 
 >>
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
Anyone have a clue on what's going on here? I've experienced a bit with
alt in other contexts, and it seem to be working just fine. So I am a bit
baffled...
Cheers,
Alf
--
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aleph-lib+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...