Hi, all

  I want to do sth. like query until timeout. So I write a function below.
(defn wait-ls-ready
  []
  (let [pair-fn (fn [] (
                         (Thread/sleep 1000)
                         (let [ret (try
                                     (c/exec :ls)
                                     0
                                     (catch RuntimeException e -1)
                                   ),
                               time-now (quot (System/currentTimeMillis) 
1000)]
                           '(ret (- time-now start-time))
                         )
                       ))]
    (loop [start-time (quot (System/currentTimeMillis) 1000)
           time-out 10]
      (let [[ret time-delta] (pair-fn)]
        (info node "Waiting gsql works...")
        (if (= 0 ret) 0
          (if (> time-delta time-out)
            (throw (RuntimeException.
                     (str "'ls' not working in " time-out "seconds.")))
            (recur start-time time-out))))
    )
  )
)

But it returns a NullpointerException after 1 seconds. Could anyone help me 
out?

Thanks,
Yihao

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to