cancellation
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user