Skip to content

Commit

Permalink
Merge pull request #44 from spencewenski/gh-43-conn-hogging
Browse files Browse the repository at this point in the history
Add a yield to prevent `Processor` from hogging redis connections
  • Loading branch information
film42 authored Apr 25, 2024
2 parents e7584e6 + a4a412e commit bb1d625
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ impl Processor {
let work = self.fetch().await?;

if work.is_none() {
// If there is no job to handle, we need to add a `yield_now` in order to allow tokio's
// scheduler to wake up another task that may be waiting to acquire a connection from
// the Redis connection pool. See the following issue for more details:
// https://github.com/film42/sidekiq-rs/issues/43
tokio::task::yield_now().await;
return Ok(WorkFetcher::NoWorkFound);
}
let mut work = work.expect("polled and found some work");
Expand Down

0 comments on commit bb1d625

Please sign in to comment.