From 964a0ecf37c46bafba3e33aceacc9f80c78d9779 Mon Sep 17 00:00:00 2001
From: Matt Jankowski <matt@jankowski.online>
Date: Thu, 4 Jan 2024 11:55:00 -0500
Subject: [PATCH] Add sleep statement to nudge thread scheduler in request pool
 spec (#28596)

---
 spec/lib/request_pool_spec.rb | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/spec/lib/request_pool_spec.rb b/spec/lib/request_pool_spec.rb
index f179e6ca9..bdb0859d7 100644
--- a/spec/lib/request_pool_spec.rb
+++ b/spec/lib/request_pool_spec.rb
@@ -33,11 +33,13 @@ describe RequestPool do
 
       subject
 
-      threads = Array.new(20) do |_i|
+      threads = Array.new(3) do
         Thread.new do
-          20.times do
+          2.times do
             subject.with('http://example.com') do |http_client|
               http_client.get('/').flush
+              # Nudge scheduler to yield and exercise the full pool
+              sleep(0)
             end
           end
         end