From ec8f12880e821f5e21b6c4db381136f9c77bb215 Mon Sep 17 00:00:00 2001 From: Kaan Barmore-Genc Date: Sun, 18 Dec 2022 00:58:51 -0500 Subject: [PATCH] Use async sleep when long running Using an async sleep just seems more appropriate as we are in an async context, although the results are identical since gandi-live-dns only uses a single thread. --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4bdb20c..75b14cf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ use config::IPSourceName; use ip_source::icanhazip::IPSourceIcanhazip; use reqwest::{header, Client, ClientBuilder, StatusCode}; use serde::Serialize; -use std::thread; +use tokio::time::sleep; use std::{num::NonZeroU32, sync::Arc, time::Duration}; use tokio::{self, task::JoinHandle}; mod config; @@ -126,7 +126,7 @@ async fn main() -> anyhow::Result<()> { if let Some(delay) = opts.repeat { loop { run_dispatch(&conf).await.ok(); - thread::sleep(Duration::from_secs(delay)) + sleep(Duration::from_secs(delay)).await } } // otherwise run just once