Puma::ThreadPool < Object
| Use Case | Command | Description |
|---|---|---|
| Create a new thread pool | Puma::ThreadPool.new(min, max, &block) | Initialize a pool with minimum and maximum thread counts, and a block to process requests |
| Add work to the pool | pool << client | Push a client request into the @todo array for processing by an available thread |
| Check pending work | pool.backlog | Returns the number of requests waiting in the @todo array |
| Check available capacity | pool.pool_capacity | Returns the number of threads available to take new work |
| Trigger graceful shutdown | pool.shutdown | Signals all threads to stop after finishing current work (not shown in snippet, but typical) |
| Force shutdown with grace | ForceShutdown exception + SHUTDOWN_GRACE_TIME | After raising ForceShutdown, wait SHUTDOWN_GRACE_TIME for threads to finish before leaving them |
Internal Docs for A simple thread pool management object.
Each Puma "worker" has a thread pool to process requests.
First a connection to a client is made in Puma::Server. It is wrapped in a Puma::Client instance and then passed to the Puma::Reactor to ensure the whole request is buffered into memory. Once the request is ready, it is passed into a thread pool via the Puma::ThreadPool#<< operator where it is stored in a @todo array.
Each thread in the pool has an internal loop where it pulls a request from the @todo array and processes it.
clean_thread_localsnewbacklogbusy_threadsclean_thread_localsout_of_band_hookpool_capacityspawnedtrim_requestedwaitingattr_accessor clean_thread_localsattr_accessor out_of_band_hookattr_reader spawnedattr_reader trim_requestedattr_reader waitingGenerated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-27 16:32 @216.73.216.194
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format