A thread-based worker pool.
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).
The current connection pulled off the Queue, or None.
A simple flag for the calling server to know when this thread has begun polling the Queue.
Process incoming HTTP connections.
Retrieves incoming connections from thread pool.
The HTTP Server which spawned this thread, and which owns the Queue and is placing active connections into it.
ThreadPool(server, min=10, max=-1, accepted_queue_size=-1, accepted_queue_timeout=10)¶
A Request Queue for an HTTPServer which pools threads.
ThreadPool objects must provide min, get(), put(obj), start() and stop(timeout) attributes.
Spawn new worker threads (not above self.max).
Number of worker threads which are idle. Read-only.
Put request into queue.
- obj (
HTTPConnection): HTTP connection
waiting to be processed
- obj (
Return the queue size.
Kill off worker threads (not below self.min).
Start the pool of threads.
Terminate all worker threads.
timeout (int): time to wait for threads to stop gracefully
HTTP workers pool.