diff options
Diffstat (limited to 'fetcher.fnl')
| -rw-r--r-- | fetcher.fnl | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/fetcher.fnl b/fetcher.fnl index 5670af9..523185d 100644 --- a/fetcher.fnl +++ b/fetcher.fnl @@ -9,26 +9,6 @@ (local http (require :lib.http)) (local {: must} (require :lib.utils)) -(fn retry [what times sleep] - (var result nil) - (var stop? false) - (var err nil) - - (for [i 1 times &until stop?] - (local (ok? value) (pcall what)) - (if ok? - (do - (set result value) - (set stop? true)) - (do - (set err value) - (os.execute (.. "sleep " sleep))))) - - (when (not stop?) - (error (.. "failed after " times " retries:\n" err))) - - result) - (fn walk-html-pages [url-formatter path item-peg] (fn gather [page knil] (local url (url-formatter path page)) @@ -44,9 +24,7 @@ (do (os.execute "sleep 1") (gather (+ page 1) (array.concat knil items))))) - (and (<= 300 status) (< status 500)) - knil - (retry #(gather page knil) 3 1))) + knil)) (gather 1 [])) @@ -92,9 +70,7 @@ (do (os.execute "sleep 1") (gather (+ 1 page) (array.concat knil items))))) - (and (<= 300 status) (< status 500)) - knil - (retry #(gather page knil) 3 1))) + knil)) (gather 1 [])) |
