From 82355356d35066586c181f794c1f1afaac9541d4 Mon Sep 17 00:00:00 2001 From: jofas Date: Fri, 25 Oct 2024 16:19:51 +0200 Subject: [PATCH] Removed race condition from global_queue_depth_multi_thread test --- tokio/tests/rt_metrics.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tokio/tests/rt_metrics.rs b/tokio/tests/rt_metrics.rs index 7adee28f917..e9f351007d5 100644 --- a/tokio/tests/rt_metrics.rs +++ b/tokio/tests/rt_metrics.rs @@ -66,10 +66,10 @@ fn global_queue_depth_current_thread() { #[test] fn global_queue_depth_multi_thread() { - let rt = threaded(); - let metrics = rt.metrics(); - for _ in 0..10 { + let rt = threaded(); + let metrics = rt.metrics(); + if let Ok(_blocking_tasks) = try_block_threaded(&rt) { for i in 0..10 { assert_eq!(i, metrics.global_queue_depth()); @@ -93,7 +93,7 @@ fn try_block_threaded(rt: &Runtime) -> Result>, mpsc::RecvT // Spawn a task per runtime worker to block it. rt.spawn(async move { - tx.send(()).unwrap(); + tx.send(()).ok(); barrier.recv().ok(); });