wait_until_i_am_the_last_task() - num_alive should be 0, not 1

This commit is contained in:
Igor Katson 2024-11-06 16:05:58 +00:00
parent 78363d65ca
commit 87e09a60f7
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
2 changed files with 6 additions and 5 deletions

View file

@ -196,13 +196,13 @@ pub async fn wait_until(
Ok(())
}
pub async fn wait_until_i_am_the_last_task() {
pub async fn wait_until_i_am_the_last_task() -> anyhow::Result<()> {
let metrics = tokio::runtime::Handle::current().metrics();
wait_until(
|| {
let num_alive = metrics.num_alive_tasks();
if num_alive != 1 {
bail!("metrics.num_alive_tasks() = {num_alive}, expected 1")
if num_alive != 0 {
bail!("metrics.num_alive_tasks() = {num_alive}, expected 0")
}
Ok(())
},
@ -210,5 +210,4 @@ pub async fn wait_until_i_am_the_last_task() {
Duration::from_secs(6),
)
.await
.unwrap();
}