cancellation

This commit is contained in:
2026-02-04 03:13:39 -08:00
parent 156df9ae86
commit 8fb0315153
9 changed files with 199 additions and 95 deletions

View File

@@ -8,14 +8,16 @@ use byteorder::{BigEndian, ReadBytesExt};
use bytes::{Buf, BytesMut};
use chrono::{DateTime, Duration, NaiveDateTime, Utc};
use figment::value::Map;
use futures::future::join;
use influxdb2::models::DataPoint;
use influxdb2::models::data_point::DataPointBuilder;
use itertools::Itertools;
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader, ReadHalf, WriteHalf};
use tokio::join;
use tokio::sync::Mutex;
use tokio::time::sleep;
use tokio::{join, select};
use tokio_serial::{SerialPort, SerialStream};
use tokio_util::sync::CancellationToken;
use tracing::{debug, info, warn};
use crate::{
@@ -596,7 +598,7 @@ impl ChimemonSource for UCCMMonitor {
}
}
async fn run(mut self, chan: ChimemonSourceChannel) {
async fn run(mut self, chan: ChimemonSourceChannel, cancel: CancellationToken) {
info!("UCCM task starting");
if self.get_info().await.is_err() {
warn!("Error starting UCCM");
@@ -622,6 +624,11 @@ impl ChimemonSource for UCCMMonitor {
// wfut.await;
// }
// });
//
select! {
_ = cancel.cancelled() => { return },
_ = rx_handle => { return }
};
join!(rx_handle).0.unwrap();
}