From 968dd2b957cc84c80b1285dcc7928b0fb14deda7 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Mon, 9 Aug 2021 16:50:09 +0100 Subject: [PATCH] Try to force new thread for msg counter to ensure it has time to print --- .../telemetry_core/src/aggregator/inner_loop.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/backend/telemetry_core/src/aggregator/inner_loop.rs b/backend/telemetry_core/src/aggregator/inner_loop.rs index 4715c9e..2426090 100644 --- a/backend/telemetry_core/src/aggregator/inner_loop.rs +++ b/backend/telemetry_core/src/aggregator/inner_loop.rs @@ -196,13 +196,15 @@ impl InnerLoop { // TEMP: let's monitor message queue len out of interest let tx_len = metered_tx.clone(); - tokio::spawn(async move { - let mut n = 0; - loop { - println!("#{} Queue len: {}", n, tx_len.len()); - n += 1; - tokio::time::sleep(tokio::time::Duration::from_millis(500)).await; - } + std::thread::spawn(move || { + tokio::runtime::Runtime::new().unwrap().block_on(async move { + let mut n = 0; + loop { + println!("#{} Queue len: {}", n, tx_len.len()); + n += 1; + tokio::time::sleep(tokio::time::Duration::from_millis(500)).await; + } + }); }); while let Some(msg) = rx_from_external.next().await {