retrying something 3 times before throwing an exception - in clojure

后端 未结 4 1310
旧时难觅i
旧时难觅i 2021-02-10 04:58

I don\'t know how to implement this piece of Python code in Clojure

for i in range(3):
    try:
        ......
    except e:
        if i == 2:
            raise         


        
4条回答
  •  我寻月下人不归
    2021-02-10 05:32

    (cond (every? nil? (for [x (range (inc retry)) :while (not @tmp-doc)]
     ...do sth) )                  
    ;all failed
    :else
    ;at least one success
    

提交回复
热议问题