metrics: fix hang in worker_overflow_count test (#6146)

Closes: #6054
This commit is contained in:
Alice Ryhl
2023-11-14 20:13:56 +01:00
committed by GitHub
parent d44e995bb0
commit e6720f985d
+9 -6
View File
@@ -471,14 +471,17 @@ fn worker_overflow_count() {
// First, we need to block the other worker until all tasks have
// been spawned.
tokio::spawn(async move {
tx1.send(()).unwrap();
rx2.recv().unwrap();
//
// We spawn from outside the runtime to ensure that the other worker
// will pick it up:
// <https://github.com/tokio-rs/tokio/issues/4730>
tokio::task::spawn_blocking(|| {
tokio::spawn(async move {
tx1.send(()).unwrap();
rx2.recv().unwrap();
});
});
// Bump the next-run spawn
tokio::spawn(async {});
rx1.recv().unwrap();
// Spawn many tasks