Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Sleep 1.5h on 429
Browse files Browse the repository at this point in the history
  • Loading branch information
imerr committed May 11, 2023
1 parent 23d165c commit aa3137e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "imgur_id7"
version = "0.1.3"
version = "0.1.4"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,15 @@ async fn main() {
let status = res.status();
if status == StatusCode::TOO_MANY_REQUESTS ||
status.is_server_error() {
println!("Failed to request '{}', got status {}, retrying in 3min", url, status.as_u16());
let dur;
if status == StatusCode::TOO_MANY_REQUESTS {
dur = 90;
} else {
dur = 3;
}
println!("Failed to request '{}', got status {}, retrying in {}min", url, status.as_u16(), dur);
tokio::select! {
_ = sleep(Duration::from_secs(180)) => {}
_ = sleep(Duration::from_secs(dur * 60)) => {}
_ = stopped.cancelled() => {
println!("Worker #{} is done.", worker_i);
return;
Expand Down

0 comments on commit aa3137e

Please sign in to comment.