def start(self):
     ''' Start all worker threads and block until done '''
     if len(self.working) == 0:
         self.working.add(self.default_worker)
     for worker in self.working:
         worker.start()
     for interval, workers in self.workers.items():
         if isinstance(workers, list):
             self.workers[interval] = utils.Cycle(workers)
     for worker in self.working:
         worker.join()
 def _get_worker(self, interval, refresh=False):
     ''' Returns a worker thread for a given interval. If max_worker_threads is
         reached, then it cycles through the existing workers
     '''
     interval_workers = self.workers.get(interval, [])
     if refresh and interval_workers:
         return next(interval_workers)
     if len(interval_workers) == self.max_worker_threads:
         if isinstance(interval_workers, list):
             interval_workers = utils.Cycle(interval_workers)
             self.workers[interval] = interval_workers
         return next(interval_workers)
     new_worker = Worker(interval, self.collector, self.output_type,
                         self.output_addr, self.use_threads,
                         self.num_threads_per_worker)
     new_worker.set_name('Worker-{}sec-{}'.format(interval,
                                                  len(interval_workers) +
                                                  1))
     interval_workers.append(new_worker)
     self.workers[interval] = interval_workers
     return new_worker