Module threadpool :: Class ThreadPool
[frames | no frames]

Class ThreadPool


A thread pool, distributing work requests and collecting results.

See the module doctring for more information.


Method Summary
  __init__(self, num_workers, q_size)
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 quit after their current task.
  poll(self, block)
Process any new results in the queue.
  putRequest(self, request, block, timeout)
Put work request into work queue and save its id for later.
  wait(self)
Wait for results, blocking until all have arrived.

Method Details

__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 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).

createWorkers(self, num_workers)

Add num_workers worker threads to the pool.

dismissWorkers(self, num_workers)

Tell num_workers worker threads to quit after their current task.

poll(self, block=False)

Process any new results in the queue.

putRequest(self, request, block=True, timeout=0)

Put work request into work queue and save its id for later.

wait(self)

Wait for results, blocking until all have arrived.


Generated by Epydoc 2.1 on Fri Jun 23 13:37:22 2006 http://epydoc.sf.net