On Sat, Jan 02, 2016 at 10:34:25PM +0100, Henrik Sarvell wrote:
> I've recently implemented pub / sub ( http://redis.io/topics/pubsub )
> in my redis class (
> (subscribe> R "foo")
> #(wait 1)
> (println "finished")
> with ./pil subscribe.l in /opt/picolisp you will see "finished".
> If you uncomment the wait line you will not see "finished", the script
> stops on (wait 1) and I have no idea why.
> Since I don't pass in a second argument I would assume that wait has
> nothing to do with the *Run global in this case and that execution
> will simply pause for one millisecond and then continue but this does
> not happen.
In fact, it has. 'wait' always first checks for pending events before it
goes to sleep. In 'subscribe>' you start a task on the socket. If there
are data available on that socket already, that task will be executed. I
can't reproduce your setup, but the task calls
where I don't know what '*RedisOnSubRes' contains, but I recommend you
trace that one to see where it hangs.
> So execution continues as soon as we get something back on the socket
> we have established.
> I don't get why wait literally needs something coming into (in ... )
> in order to allow continued execution in this case.
If nothing would be coming in, 'wait' would indeed sleep just for
a millisecond and then return. So it must be the scenario described