Processes the tasks.

def ProcessTask(self, target, args, name, queueing_time):
    """Processes the tasks."""

    if self.pool.name:
      time_in_queue = time.time() - queueing_time
      stats_collector_instance.Get().RecordEvent(
          _QUEUEING_TIME_METRIC, time_in_queue, fields=[self.pool.name])

      start_time = time.time()
    try:
      target(*args)
    # We can't let a worker die because one of the tasks it has to process
    # throws an exception. Therefore, we catch every error that is
    # raised in the call to target().
    except Exception as e:  # pylint: disable=broad-except
      if self.pool.name:
        stats_collector_instance.Get().IncrementCounter(
            _TASK_EXCEPTIONS_METRIC, fields=[self.pool.name])
      logging.exception("Caught exception in worker thread (%s): %s", name,
                        str(e))

    if self.pool.name:
      total_time = time.time() - start_time
      stats_collector_instance.Get().RecordEvent(
          _WORKING_TIME_METRIC, total_time, fields=[self.pool.name])