cheroot.workers package¶
Submodules¶
cheroot.workers.threadpool module¶
A thread-based worker pool.
-
class
cheroot.workers.threadpool.
ThreadPool
(server, min=10, max=- 1, accepted_queue_size=- 1, accepted_queue_timeout=10)¶ Bases:
object
A Request Queue for an HTTPServer which pools threads.
ThreadPool objects must provide min, get(), put(obj), start() and stop(timeout) attributes.
-
grow
(amount)¶ Spawn new worker threads (not above self.max).
-
property
idle
¶ Number of worker threads which are idle. Read-only.
-
put
(obj)¶ Put request into queue.
- Args:
- obj (
HTTPConnection
): HTTP connection waiting to be processed
- obj (
-
property
qsize
¶ Return the queue size.
-
shrink
(amount)¶ Kill off worker threads (not below self.min).
-
start
()¶ Start the pool of threads.
-
stop
(timeout=5)¶ Terminate all worker threads.
- Args:
timeout (int): time to wait for threads to stop gracefully
-
-
class
cheroot.workers.threadpool.
WorkerThread
(server)¶ Bases:
threading.Thread
Thread which continuously polls a Queue for Connection objects.
Due to the timing issues of polling a Queue, a WorkerThread does not check its own ‘ready’ flag after it has started. To stop the thread, it is necessary to stick a _SHUTDOWNREQUEST object onto the Queue (one for each running WorkerThread).
-
conn
= None¶ The current connection pulled off the Queue, or None.
-
ready
= False¶ A simple flag for the calling server to know when this thread has begun polling the Queue.
-
run
()¶ Process incoming HTTP connections.
Retrieves incoming connections from thread pool.
-
server
= None¶ The HTTP Server which spawned this thread, and which owns the Queue and is placing active connections into it.
-
Module contents¶
HTTP workers pool.