From 2189b082c015ca436207574f8255ceb7c4b1bccc Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 30 Apr 2024 15:56:21 +0200 Subject: [PATCH] use recommended method of 'sleep' --- src/scheduled/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/scheduled/mod.rs b/src/scheduled/mod.rs index 381a546..a27df12 100644 --- a/src/scheduled/mod.rs +++ b/src/scheduled/mod.rs @@ -3,7 +3,7 @@ mod waterlevel; use std::time::Duration; use job_scheduler_ng::{Job, JobScheduler}; -use rocket::tokio::{self, task}; +use rocket::tokio::{self, task, time}; use sqlx::SqlitePool; pub fn schedule(db: &SqlitePool) { @@ -26,9 +26,10 @@ pub fn schedule(db: &SqlitePool) { }); })); + let mut interval = time::interval(Duration::from_secs(60)); loop { sched.tick(); - std::thread::sleep(Duration::from_secs(60)); + interval.tick().await; } }); } -- 2.45.2