diff --git a/test/async/pool/controller.rb b/test/async/pool/controller.rb index c3cb8a9..25708d7 100644 --- a/test/async/pool/controller.rb +++ b/test/async/pool/controller.rb @@ -486,4 +486,19 @@ def failures(repeats: 500, time_scale: 0.001, &block) pool.close end end + + with "cancellation while waiting" do + it "cancels the gardener when closing the pool" do + # Regression test for https://bugs.ruby-lang.org/issues/20907. + # Allocating a resource starts the gardener, which then parks in `#wait`: + resource = pool.acquire + gardener = pool.instance_variable_get(:@gardener) + pool.release(resource) + + # This stops the gardener while it is waiting: + pool.close + + expect(gardener.wait).to be_nil + end + end end