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]]
name = "tesla-charge-controller"
version = "1.0.30"
version = "1.0.31"
dependencies = [
"chrono",
"clap 4.4.11",

View file

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

View file

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