How to make a Clojure go loop run forever -


i want use clojure core.async write application sits in loop polling service, attempts far terminate unexpectedly.

when run program prints message exits:

(defn -main   []   (println "running forever...?")   (async/go-loop [n 0]                  (prn n)                  (async/<!! (async/timeout 1000))                  (recur (inc n)))) 

i program run forever (until jvm process killed).

what accepted way achieve this?

the main thread keep jvm process running (it won't care threads in go pool).

keep running blocking on main thread. e.g.

(defn -main   []   (println "running forever...?")   (async/<!! (async/go-loop [n 0]                  (prn n)                  (async/<! (async/timeout 1000))                  (recur (inc n))))) 

note: shouldn't use <!! inside of go block. should instead use <!.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -