fixes history loading slowly due to context switches
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
mod grpc;
|
||||
mod http;
|
||||
mod serialization;
|
||||
mod telemetry;
|
||||
mod uuid;
|
||||
|
||||
@@ -11,6 +12,8 @@ use crate::telemetry::history::TelemetryHistoryService;
|
||||
use crate::telemetry::management_service::TelemetryManagementService;
|
||||
use log::error;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use tokio::time::sleep;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
pub async fn setup() -> anyhow::Result<()> {
|
||||
@@ -35,7 +38,14 @@ pub async fn setup() -> anyhow::Result<()> {
|
||||
grpc_server.await?; //grpc server is dropped
|
||||
drop(cancellation_token); // All cancellation tokens are now dropped
|
||||
|
||||
error!("after awaits");
|
||||
|
||||
// Perform cleanup functions - at this point all servers have stopped and we can be sure that cleaning things up is safe
|
||||
for _ in 0..15 {
|
||||
if Arc::strong_count(&tlm) != 1 {
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
}
|
||||
}
|
||||
if let Some(tlm) = Arc::into_inner(tlm) {
|
||||
tlm.cleanup().await?;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user