Skip to content

Commit

Permalink
fix(console): lints trigger with non-async tasks
Browse files Browse the repository at this point in the history
change existing lints to only trigger with tasks that are async; those
are all except those with kind 'blocking' and 'block_on'

this commit fixes issue tokio-rs#516
  • Loading branch information
javihernant committed Feb 7, 2024
1 parent b0e3196 commit 91d5134
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tokio-console/src/warnings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ impl Warn<Task> for SelfWakePercent {
}

fn check(&self, task: &Task) -> Warning {
// Don't fire warning for tasks that are not async
if task.kind() == "block_on" || task.kind() == "blocking" {
return Warning::Ok
}
let self_wakes = task.self_wake_percent();
if self_wakes > self.min_percent {
Warning::Warn
Expand All @@ -174,6 +178,10 @@ impl Warn<Task> for LostWaker {
}

fn check(&self, task: &Task) -> Warning {
// Don't fire warning for tasks that are not async
if task.kind() == "block_on" || task.kind() == "blocking" {
return Warning::Ok
}
if !task.is_completed()
&& task.waker_count() == 0
&& !task.is_running()
Expand Down Expand Up @@ -222,6 +230,10 @@ impl Warn<Task> for NeverYielded {
}

fn check(&self, task: &Task) -> Warning {
// Don't fire warning for tasks that are not async
if task.kind() == "block_on" || task.kind() == "blocking" {
return Warning::Ok
}
// Don't fire warning for tasks that are waiting to run
if task.state() != TaskState::Running {
return Warning::Ok;
Expand Down

0 comments on commit 91d5134

Please sign in to comment.