'Create thread pool with `nworkers` worker threads.'

def __init__(self, nworkers, name='ThreadPool', daemon=False, max_requests=100, hung_thread_limit=30, kill_thread_limit=1800, dying_limit=300, spawn_if_under=5, max_zombie_threads_before_die=0, hung_check_period=100, logger=None, error_email=None):

    self.nworkers = nworkers
    self.max_requests = max_requests
    self.name = name
    self.queue = queue.Queue()
    self.workers = []
    self.daemon = daemon
    if (logger is None):
        logger = logging.getLogger('paste.httpserver.ThreadPool')
    if isinstance(logger, six.string_types):
        logger = logging.getLogger(logger)
    self.logger = logger
    self.error_email = error_email
    self._worker_count = count()
    assert ((not kill_thread_limit) or (kill_thread_limit >= hung_thread_limit)), ('kill_thread_limit    (%s)    should    be    higher    than    hung_thread_limit    (%s)' % (kill_thread_limit, hung_thread_limit))
    if (not killthread):
        kill_thread_limit = 0
        self.logger.info('Cannot    use    kill_thread_limit    as    ctypes/killthread    is    not    available')
    self.kill_thread_limit = kill_thread_limit
    self.dying_limit = dying_limit
    self.hung_thread_limit = hung_thread_limit
    assert (spawn_if_under <= nworkers), ('spawn_if_under    (%s)    should    be    less    than    nworkers    (%s)' % (spawn_if_under, nworkers))
    self.spawn_if_under = spawn_if_under
    self.max_zombie_threads_before_die = max_zombie_threads_before_die
    self.hung_check_period = hung_check_period
    self.requests_since_last_hung_check = 0
    self.worker_tracker = {}
    self.idle_workers = []
    self.dying_threads = {}
    self._last_added_new_idle_workers = 0
    if (not daemon):
        atexit.register(self.shutdown)
    for i in range(self.nworkers):
        self.add_worker_thread(message='Initial    worker    pool')
