سؤال

all to often when I'm using core.async from the repl a go block will get away from me because I loose the channel that is used to stop it because I reload a namespace. For instance if i run this from the repl:

(go (when (not= c (second (async/alts! [c (async/timeout 1000)]))) 
      (println "hello")))

and then I reload the namespace and c is lost. Now I have "hello" spamming my REPL until the end of time. If I could close all channels or kill all go blocks it would save me restarting my REPL.

هل كانت مفيدة؟

المحلول

There is no way to do this globally that I know of. One technique is to use a control channel that can be used to shut down any loop. The pub/sub stuff might work well for a global control channel.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top