Check whether a task has completed.

        :param task_id: task ID
        :type task_id: str

        :return: True if completed, False otherwise
        :rtype: bool
335296
def task_completed(task_id):
    

    tasks = get_tasks(task_id=task_id)
    completed_states = ('TASK_FINISHED',
                        'TASK_FAILED',
                        'TASK_KILLED',
                        'TASK_LOST',
                        'TASK_ERROR')

    for task in tasks:
        if task['state'] in completed_states:
            return True

    return False
814454
def task_progress(task_or_id)
      task_id = task_or_id.is_a?(Hash) ? task_or_id['id'] : task_or_id
      if !task_id.empty?
        options = { verbosity: @context[:verbosity] || HammerCLI::V_VERBOSE }
        task_progress = TaskProgress.new(task_id, options) { |id| load_task(id) }
        task_progress.render
        task_progress.success?
      else
        signal_usage_error(_('Please mention appropriate attribute value'))
      end
    end
48006
def get_completed_task(self, task, timeout=-1):
        
        self.__wait_task_completion(task, timeout)

        return self.get(task)
1249784
def approve_task(self, task_id):
        
        uri = 'tasks/%s' % task_id

        data = {"approved": True}

        resp, body = self.post(uri, json.dumps(data))
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)
980838
void alreadyCompletedTask(TaskAttemptID taskid) {
    // 'KILL' the task 
    completedTask(taskid, TaskStatus.State.KILLED);
    
    // Note the reason for the task being 'KILLED'
    addDiagnosticInfo(taskid, "Already completed TIP");
    
    LOG.info("Already complete TIP " + getTIPId() + 
             " has completed task " + taskid);
  }
481940
def has_completed(self):
        """"""
        objects_in_db = WorkflowObjectModel.query.filter(
            WorkflowObjectModel.id_workflow == self.uuid,
            WorkflowObjectModel.id_parent == None,  # noqa
        ).filter(WorkflowObjectModel.status.in_([
            workflow_object_class.known_statuses.COMPLETED
        ])).count()
        return objects_in_db == len(list(self.objects))
600738
def get_task_id(self):
        """"""
        task_id = self.json_response.get("task_id", None)
        self.logger.info("%s\t%s" % (self.request_method, self.request_url))
        return task_id
366377
def _check_stage_complete(self):
        

        try:

            for task in self._tasks:
                if task.state not in [states.DONE, states.FAILED]:
                    return False

            return True

        except Exception, ex:
            raise EnTKError(ex)
85641
def _monitor_task(self):
        
        if self.task.state in states.UNREADY_STATES:
            reactor.callLater(self.POLL_PERIOD, self._monitor_task)
            return

        if self.task.state == 'SUCCESS':
            self.callback(self.task.result)
        elif self.task.state == 'FAILURE':
            self.errback(Failure(self.task.result))
        elif self.task.state == 'REVOKED':
            self.errback(
                Failure(defer.CancelledError('Task {0}'.format(self.task.id))))
        else:
            self.errback(ValueError(
                'Cannot respond to `{}` state'.format(self.task.state)
            ))
1371952
def on_result(self, task, result):
        ''''''
        if not result:
            return
        if 'taskid' in task and 'project' in task and 'url' in task:
            logger.info('result %s:%s %s -> %.30r' % (
                task['project'], task['taskid'], task['url'], result))
            print(json.dumps({
                'taskid': task['taskid'],
                'project': task['project'],
                'url': task['url'],
                'result': result,
                'updatetime': time.time()
            }))
        else:
            logger.warning('result UNKNOW -> %.30r' % result)
            return
731071
def get_tasks(client, list_id, completed=False):
    '''  '''
    params = { 
            'list_id' : str(list_id), 
            'completed' : completed 
            }
    response = client.authenticated_request(client.api.Endpoints.TASKS, params=params)
    return response.json()
482140
def effective_task_id(self):
        
        params = self.param_kwargs
        if 'date' in params and is_closest_date_parameter(self, 'date'):
            params['date'] = self.closest()
            task_id_parts = sorted(['%s=%s' % (k, str(v)) for k, v in params.items()])
            return '%s(%s)' % (self.task_family, ', '.join(task_id_parts))
        else:
            return self.task_id
255282
def check_complete(self):
        
        logger.debug('Running check_complete for task {0}'.format(self.name))

        # Tasks not completed
        if self.remote_not_complete() or self.local_not_complete():
            self._start_check_timer()
            return

        return_code = self.completed_task()

        # Handle task errors
        if self.terminate_sent:
            self.stderr += '\nDAGOBAH SENT SIGTERM TO THIS PROCESS\n'
        if self.kill_sent:
            self.stderr += '\nDAGOBAH SENT SIGKILL TO THIS PROCESS\n'
        if self.remote_failure:
            return_code = -1
            self.stderr += '\nAn error occurred with the remote machine.\n'

        self.stdout_file = None
        self.stderr_file = None

        self._task_complete(success=True if return_code == 0 else False,
                            return_code=return_code,
                            stdout=self.stdout,
                            stderr=self.stderr,
                            start_time=self.started_at,
                            complete_time=datetime.utcnow())
239668
synchronized public boolean isBlacklisted(String trackerID) {
    TaskTrackerStatus status = getTaskTrackerStatus(trackerID);
    if (status != null) {
      return faultyTrackers.isBlacklisted(status.getHost());
    }
    return false;
  }
53979
def get_task_subtasks(client, task_id, completed=False):
    '''  '''
    params = {
            'task_id' : int(task_id),
            'completed' : completed,
            }
    response = client.authenticated_request(client.api.Endpoints.SUBTASKS, params=params)
    return response.json()
14693
def find_task_by_id(self, id, session=None):
        
        with self._session(session) as session:
            return session.query(TaskRecord).get(id)
1151033
public function stopTask($task_id)
    {
        $task_pid = get_instance()->tid_pid_table->get($task_id)['pid'];
        if ($task_pid != null) {
            posix_kill($task_pid, SIGKILL);
            get_instance()->tid_pid_table->del($task_id);
        }
    }