'Add a task to the queue'

def add_task(self, task):

    self.logger.debug('Added    task    (%i    tasks    queued)', self.queue.qsize())
    if self.hung_check_period:
        self.requests_since_last_hung_check += 1
        if (self.requests_since_last_hung_check > self.hung_check_period):
            self.requests_since_last_hung_check = 0
            self.kill_hung_threads()
    if ((not self.idle_workers) and self.spawn_if_under):
        busy = 0
        now = time.time()
        self.logger.debug('No    idle    workers    for    task;    checking    if    we    need    to    make    more    workers')
        for worker in self.workers:
            if (not hasattr(worker, 'thread_id')):
                continue
            (time_started, info) = self.worker_tracker.get(worker.thread_id, (None, None))
            if (time_started is not None):
                if ((now - time_started) < self.hung_thread_limit):
                    busy += 1
        if (busy < self.spawn_if_under):
            self.logger.info('No    idle    tasks,    and    only    %s    busy    tasks;    adding    %s    more    workers', busy, (self.spawn_if_under - busy))
            self._last_added_new_idle_workers = time.time()
            for i in range((self.spawn_if_under - busy)):
                self.add_worker_thread(message='Response    to    lack    of    idle    workers')
        else:
            self.logger.debug('No    extra    workers    needed    (%s    busy    workers)', busy)
    if ((len(self.workers) > self.nworkers) and (len(self.idle_workers) > 3) and ((time.time() - self._last_added_new_idle_workers) > self.hung_thread_limit)):
        self.logger.info('Culling    %s    extra    workers    (%s    idle    workers    present)', (len(self.workers) - self.nworkers), len(self.idle_workers))
        self.logger.debug('Idle    workers:    %s', self.idle_workers)
        for i in range((len(self.workers) - self.nworkers)):
            self.queue.put(self.SHUTDOWN)
    self.queue.put(task)
