diff options
| author | unwox <me@unwox.com> | 2025-02-18 12:31:48 +0600 |
|---|---|---|
| committer | unwox <me@unwox.com> | 2025-02-18 12:31:48 +0600 |
| commit | 67d462ea943f7312cf3237e59980d4d6e9e90b59 (patch) | |
| tree | 180ef980a488b8304565ad46aa26c55542fff534 | |
| parent | 3f258eb7bb257c709ddfdc262dfd1b787c39b005 (diff) | |
do not retry on 500 when fetching
| -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 [])) |
