'This creates a new thread pool using min_threads workers.
Args:
name: A prefix to identify this thread pool in the exported stats.
min_threads: The minimum number of worker threads this pool should have.
max_threads: The maximum number of threads to grow the pool to. If not set
we do not grow the pool.
Raises:
threading.ThreadError: If no threads can be spawned at all, ThreadError
will be raised.
DuplicateThreadpoolError: This exception is raised if a thread pool with
the desired name already exists.'

def __init__(self, name, min_threads, max_threads=None):

    self.min_threads = min_threads
    if ((max_threads is None) or (max_threads < min_threads)):
        max_threads = min_threads
    self.max_threads = max_threads
    self._queue = Queue.Queue(maxsize=max_threads)
    self.name = name
    self.started = False
    self.process = psutil.Process(os.getpid())
    self._workers = {}
    self._workers_ro_copy = {}
    self.lock = threading.RLock()
    if self.name:
        if (self.name in self.POOLS):
            raise DuplicateThreadpoolError('A    thread    pool    with    the    name    %s    already    exists.', name)
        stats.STATS.RegisterGaugeMetric((self.name + '_outstanding_tasks'), int)
        stats.STATS.SetGaugeCallback((self.name + '_outstanding_tasks'), self._queue.qsize)
        stats.STATS.RegisterGaugeMetric((self.name + '_threads'), int)
        stats.STATS.SetGaugeCallback((self.name + '_threads'), (lambda : len(self)))
        stats.STATS.RegisterGaugeMetric((self.name + '_cpu_use'), float)
        stats.STATS.SetGaugeCallback((self.name + '_cpu_use'), self.CPUUsage)
        stats.STATS.RegisterCounterMetric((self.name + '_task_exceptions'))
        stats.STATS.RegisterEventMetric((self.name + '_working_time'))
        stats.STATS.RegisterEventMetric((self.name + '_queueing_time'))
