Skip to content

Commit 070a825

Browse files
authored
metrics: removed race condition from global_queue_depth_multi_thread test (#6936)
1 parent 946401c commit 070a825

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tokio/tests/rt_metrics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ fn global_queue_depth_current_thread() {
6666

6767
#[test]
6868
fn global_queue_depth_multi_thread() {
69-
let rt = threaded();
70-
let metrics = rt.metrics();
71-
7269
for _ in 0..10 {
70+
let rt = threaded();
71+
let metrics = rt.metrics();
72+
7373
if let Ok(_blocking_tasks) = try_block_threaded(&rt) {
7474
for i in 0..10 {
7575
assert_eq!(i, metrics.global_queue_depth());
@@ -93,7 +93,7 @@ fn try_block_threaded(rt: &Runtime) -> Result<Vec<mpsc::Sender<()>>, mpsc::RecvT
9393

9494
// Spawn a task per runtime worker to block it.
9595
rt.spawn(async move {
96-
tx.send(()).unwrap();
96+
tx.send(()).ok();
9797
barrier.recv().ok();
9898
});
9999

0 commit comments

Comments
 (0)