mirror of
https://github.com/rust-unofficial/awesome-rust
synced 2025-02-17 20:58:26 +00:00
Only write every so often
This commit is contained in:
parent
b4cea8a4c2
commit
edc17508e1
1 changed files with 11 additions and 1 deletions
12
src/main.rs
12
src/main.rs
|
@ -261,6 +261,8 @@ async fn main() -> Result<(), Error> {
|
|||
}
|
||||
fs::write("results/results.yaml", serde_yaml::to_string(&results)?)?;
|
||||
|
||||
let mut not_written = 0;
|
||||
let mut last_written = Local::now();
|
||||
while url_checks.len() > 0 {
|
||||
debug!("Waiting...");
|
||||
let ((url, res), _index, remaining) = select_all(url_checks).await;
|
||||
|
@ -324,8 +326,16 @@ async fn main() -> Result<(), Error> {
|
|||
}
|
||||
}
|
||||
std::io::stdout().flush().unwrap();
|
||||
fs::write("results/results.yaml", serde_yaml::to_string(&results)?)?;
|
||||
|
||||
not_written += 1;
|
||||
let duration = Local::now() - last_written;
|
||||
if duration > Duration::seconds(5) || not_written > 20 {
|
||||
fs::write("results/results.yaml", serde_yaml::to_string(&results)?)?;
|
||||
not_written = 0;
|
||||
last_written = Local::now();
|
||||
}
|
||||
}
|
||||
fs::write("results/results.yaml", serde_yaml::to_string(&results)?)?;
|
||||
println!("");
|
||||
let mut failed: u32 = 0;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue