__init__(self,
num_workers,
q_size=0,
resq_size=0,
poll_timeout=5)
(Constructor)
| source code
|
Set up the thread pool and start num_workers worker threads.
num_workers is the number of worker threads to start initially.
If q_size > 0 the size of the work request queue is limited and
the thread pool blocks when the queue is full and it tries to put
more work requests in it (see putRequest method), unless you also
use a positive timeout value for putRequest.
If resq_size > 0 the size of the results queue is limited and the
worker threads will block when the queue is full and they try to put
new results in it.
Warning
If you set both q_size and resq_size to != 0 there is
the possibilty of a deadlock, when the results queue is not pulled
regularly and too many jobs are put in the work requests queue.
To prevent this, always set timeout > 0 when calling
ThreadPool.putRequest() and catch Queue.Full exceptions.
|