Returns a :class:`Counter` object that counts the number of tasks with
        given status (use the string representation of the status as key).
165538
def status_counter(self):
        
        # Count the number of tasks with given status in each work.
        counter = self[0].status_counter
        for work in self[1:]:
            counter += work.status_counter

        return counter
263786
def status(task_id)
      uri = 'api/status'
      params = {
        appkey: @appkey,
        timestamp: Time.now.to_i,
        task_id: task_id
      }
      request(uri, params)
    end
981273
def status(self):
        
        task_id = self.request.id
        try:
            # Most calls are for existing objects, don't waste time
            # preparing creation arguments unless necessary
            return UserTaskStatus.objects.get(task_id=task_id)
        except UserTaskStatus.DoesNotExist:
            # Probably an eager task that skipped the before_task_publish
            # signal (or an atomic view where the new record hasn't been
            # committed yet).  Create a record for it.
            arguments_dict = self.arguments_as_dict(*self.request.args, **self.request.kwargs)
            name = self.generate_name(arguments_dict)
            task_class = '.'.join([self.__class__.__module__, self.__class__.__name__])
            total_steps = self.calculate_total_steps(arguments_dict)
            user_id = arguments_dict['user_id']
            # Use get_or_create() again just in case another process created it in the meantime
            return UserTaskStatus.objects.get_or_create(
                task_id=task_id, defaults={'user_id': user_id, 'name': name, 'task_class': task_class,
                                           'total_steps': total_steps})[0]
118538
public int countMapTasks() {
    int mapCount = 0;
    for (Iterator<TaskStatus> it = taskReports.iterator(); it.hasNext();) {
      TaskStatus ts = (TaskStatus) it.next();
      if (ts.getIsMap() && isTaskRunning(ts)) {
        mapCount++;
      }
    }
    return mapCount;
  }
425477
def n_tasks(dec_num):
    
    bitstring = ""
    try:
        bitstring = dec_num[2:]
    except:
        bitstring = bin(int(dec_num))[2:]  # cut off 0b
    # print bin(int(dec_num)), bitstring
    return bitstring.count("1")
68012
def count(self, *args, **kw):
        
        obj = args[0]
        if self.method_name in obj._memo:
            self.hit = self.hit + 1
        else:
            self.miss = self.miss + 1
976335
def count(self, *args, **kw):
        
        obj = args[0]
        try:
            memo_dict = obj._memo[self.method_name]
        except KeyError:
            self.miss = self.miss + 1
        else:
            key = self.keymaker(*args, **kw)
            if key in memo_dict:
                self.hit = self.hit + 1
            else:
                self.miss = self.miss + 1
883442
def next(self, task):
        
        uuid = str(task.uuid)
        for idx, otask in enumerate(self.tasks[:-1]):
            if otask.uuid == uuid:
                if self.tasks[idx + 1].status != 'SUCCESS':
                    return self.tasks[idx + 1]
                else:
                    uuid = self.tasks[idx + 1].uuid
1093071
def count_buildable_tasks(self):
        """"""
        self.update_tasks_status()
        buildable_tasks_count = 0
        for key, task in self.tasks.iteritems():
            if task.state is Task.State.NEW:
                if self.are_dependencies_buildable(task):
                    buildable_tasks_count += 1
                    logging.debug("Buildable task: %s" % task.name )
                else:
                    logging.debug("Task %s has broken dependencies." % task.name )

        return buildable_tasks_count
803478
def stats(self, name, value):
        
        for counter in self._counters:
            counter.stats(name, value)
49784
def do_status(self, args):
        ''''''
        work_spec_name = self._get_work_spec_name(args)
        status = self.task_master.status(work_spec_name)
        self.stdout.write(json.dumps(status, indent=4, sort_keys=True) +
                          '\n')
666375
def num_pending_tasks(self):
        
        return len(self._status_tasks[PENDING]) + len(self._status_tasks[RUNNING])
970128
def get_task_progress(self, task_name):
        

        params = {'instanceprogress': task_name, 'taskname': task_name}

        resp = self._client.get(self.resource(), params=params)
        return Instance.Task.TaskProgress.parse(self._client, resp)
513235
def groupby_status(self):
        
        Entry = collections.namedtuple("Entry", "task wi ti")
        d = collections.defaultdict(list)

        for task, wi, ti in self.iflat_tasks_wti():
            d[task.status].append(Entry(task, wi, ti))

        # Sort keys according to their status.
        return OrderedDict([(k, d[k]) for k in sorted(list(d.keys()))])
531620
def counter(self, counter_name, default=0):
    
    return self._state.counters_map.get(counter_name, default)
933204
def _get_task_statuses(task_ids, cluster):
    
    response = client.describe_tasks(tasks=task_ids, cluster=cluster)

    # Error checking
    if response['failures'] != []:
        raise Exception('There were some failures:\n{0}'.format(
            response['failures']))
    status_code = response['ResponseMetadata']['HTTPStatusCode']
    if status_code != 200:
        msg = 'Task status request received status code {0}:\n{1}'
        raise Exception(msg.format(status_code, response))

    return [t['lastStatus'] for t in response['tasks']]
837807
def counter(module, name, count=1):
    
    counter = get_metric('counters', module, name, Counter())
    counter.inc(count)