Package core :: Package controllers :: Package threads :: Module threadpool :: Class ThreadPool
[hide private]
[frames] | no frames]

Class ThreadPool



A thread pool, distributing work requests and collecting results.

See the module doctring for more information.

Instance Methods [hide private]
  __init__(self, num_workers, q_size=0)
Set up the thread pool and start num_workers worker threads.
  createWorkers(self, num_workers)
Add num_workers worker threads to the pool.
  dismissWorkers(self, num_workers)
Tell num_workers worker threads to to quit when they're done.
  putRequest(self, request)
Put work request into work queue and save for later.
  poll(self, block=False, ownerObj=None, joinAll=False)
Process any new results in the queue.
  wait(self, ownerObj=None, joinAll=False)
Wait for results, blocking until all have arrived.

Method Details [hide private]

__init__(self, num_workers, q_size=0)
(Constructor)

 

Set up the thread pool and start num_workers worker threads.

num_workers is the number of worker threads to start initialy. If q_size > 0 the size of the work request is limited and the thread pool blocks when queue is full and it tries to put more work requests in it.

createWorkers(self, num_workers)

 
Add num_workers worker threads to the pool.

dismissWorkers(self, num_workers)

 
Tell num_workers worker threads to to quit when they're done.

putRequest(self, request)

 
Put work request into work queue and save for later.

poll(self, block=False, ownerObj=None, joinAll=False)

 
Process any new results in the queue.

wait(self, ownerObj=None, joinAll=False)

 
Wait for results, blocking until all have arrived.