spawn on local set
All checks were successful
Build .deb on release / Build-Deb (push) Successful in 1m54s

This commit is contained in:
Alex Janka 2024-01-27 16:49:57 +11:00
parent 7f4a880720
commit 9d9755515d
3 changed files with 5 additions and 6 deletions

2
Cargo.lock generated
View file

@ -2633,7 +2633,7 @@ dependencies = [
[[package]] [[package]]
name = "tesla-charge-controller" name = "tesla-charge-controller"
version = "1.0.30" version = "1.0.31"
dependencies = [ dependencies = [
"chrono", "chrono",
"clap 4.4.11", "clap 4.4.11",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "tesla-charge-controller" name = "tesla-charge-controller"
version = "1.0.30" version = "1.0.31"
edition = "2021" edition = "2021"
license = "MITNFA" license = "MITNFA"
description = "Controls Tesla charge rate based on solar charge data" description = "Controls Tesla charge rate based on solar charge data"

View file

@ -108,7 +108,7 @@ async fn main() {
None None
} }
}; };
let local = tokio::task::LocalSet::new();
// spawn a loop for each additional charge controller to log // spawn a loop for each additional charge controller to log
// failed connections will print an error but the program will continue // failed connections will print an error but the program will continue
let _additional_controllers: Vec<_> = access_config() let _additional_controllers: Vec<_> = access_config()
@ -141,7 +141,7 @@ async fn main() {
} => Tristar::new(serial_port.clone(), baud_rate) } => Tristar::new(serial_port.clone(), baud_rate)
.some_or_print_with("Failed to connect to additional Tristar") .some_or_print_with("Failed to connect to additional Tristar")
.map(|mut tristar| { .map(|mut tristar| {
tokio::task::spawn_local(async move { local.spawn_local(async move {
let mut interval = tokio::time::interval( let mut interval = tokio::time::interval(
std::time::Duration::from_secs(watch_interval_seconds), std::time::Duration::from_secs(watch_interval_seconds),
); );
@ -219,8 +219,7 @@ async fn main() {
} }
} }
}); });
tokio::join!(server_handle, local);
server_handle.await;
} }
} }
} }