Returns task status and result in JSON format.
18053
def task_status(request, task_id):
    """"""
    result = AsyncResult(task_id)
    state, retval = result.state, result.result
    response_data = {'id': task_id, 'status': state, 'result': retval}
    if state in states.EXCEPTION_STATES:
        traceback = result.traceback
        response_data.update({'result': safe_repr(retval),
                              'exc': get_full_cls_name(retval.__class__),
                              'traceback': traceback})
    return JsonResponse({'task': response_data})
134932
def GetStatusInformation(self):
    
    status = processing_status.TasksStatus()

    with self._lock:
      status.number_of_abandoned_tasks = len(self._tasks_abandoned)
      status.number_of_queued_tasks = len(self._tasks_queued)
      status.number_of_tasks_pending_merge = (
          len(self._tasks_pending_merge) + len(self._tasks_merging))
      status.number_of_tasks_processing = len(self._tasks_processing)
      status.total_number_of_tasks = self._total_number_of_tasks

    return status
685784
def status(self, event):
        """"""
        result = AsyncResult(str(event.id))
        return (
            self.CELERY_STATES_TO_HTTP.get(result.state),
            result.info.get('message')
            if result.state in self.CELERY_RESULT_INFO_FOR and result.info
            else event.response.get('message')
        )
1022113
async def status(self) -> JobStatus:
        
        if await self._redis.exists(result_key_prefix + self.job_id):
            return JobStatus.complete
        elif await self._redis.exists(in_progress_key_prefix + self.job_id):
            return JobStatus.in_progress
        else:
            score = await self._redis.zscore(queue_name, self.job_id)
            if not score:
                return JobStatus.not_found
            return JobStatus.deferred if score > timestamp_ms() else JobStatus.queued
94434
def _get_async_status(self, response):
        
        if self._is_empty(response):
            return None
        body = self._as_json(response)
        return body.get('status')
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()
822351
def on_task_status(self, task):
        ''''''
        try:
            procesok = task['track']['process']['ok']
            if not self.projects[task['project']].task_queue.done(task['taskid']):
                logging.error('not processing pack: %(project)s:%(taskid)s %(url)s', task)
                return None
        except KeyError as e:
            logger.error("Bad status pack: %s", e)
            return None

        if procesok:
            ret = self.on_task_done(task)
        else:
            ret = self.on_task_failed(task)

        if task['track']['fetch'].get('time'):
            self._cnt['5m_time'].event((task['project'], 'fetch_time'),
                                       task['track']['fetch']['time'])
        if task['track']['process'].get('time'):
            self._cnt['5m_time'].event((task['project'], 'process_time'),
                                       task['track']['process'].get('time'))
        self.projects[task['project']].active_tasks.appendleft((time.time(), task))
        return ret
447995
def status(self, status_id, raise_exception_on_failure=False):
        """"""
        query = {"output": "json", "user_credentials": self.api_key}

        resp = requests.get(
            "%sstatus/%s" % (self._url, status_id), params=query, timeout=self._timeout
        )

        if raise_exception_on_failure and resp.status_code != 200:
            raise DocumentStatusFailure(resp.content, resp.status_code)

        if resp.status_code == 200:
            as_json = json.loads(resp.content)
            if as_json["status"] == "completed":
                as_json["download_key"] = _get_download_key(as_json["download_url"])
            return as_json
        return resp
409621
def get_all_status(self, only_min=False):
        
        if len(self) == 0:
            # The work will be created in the future.
            if only_min:
                return self.S_INIT
            else:
                return [self.S_INIT]

        self.check_status()
        status_list = [task.status for task in self]

        if only_min:
            return min(status_list)
        else:
            return status_list
568428
@Override
  public TaskStatus getTaskStatus(final JobId jobId) {
    final byte[] data = taskStatuses.get(jobId.toString());
    if (data == null) {
      return null;
    }
    try {
      return parse(data, TaskStatus.class);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
761614
def tasks(self):
        ''''''
        tasks_response = self.get_request('tasks/')
        return [Task(self, tjson['task']) for tjson in tasks_response]
465974
def do_some_work(
        self,
        work_dict):
    

    label = "do_some_work"

    log.info(("task - {} - start "
              "work_dict={}")
             .format(label,
                     work_dict))

    ret_data = {
        "job_results": ("some response key={}").format(
                            str(uuid.uuid4()))
    }

    log.info(("task - {} - result={} done")
             .format(
                 ret_data,
                 label))

    return ret_data
1038072
def get_status(self):
        """"""
        return {
            "host": self.__hostid,
            "status": self._service_status_announced,
            "statustext": CommonService.human_readable_state.get(
                self._service_status_announced
            ),
            "service": self._service_name,
            "serviceclass": self._service_class_name,
            "utilization": self._utilization.report(),
            "workflows": workflows.version(),
        }
908595
public TaskStatus pollTaskStatus(String taskId, Map<String, String> reqHeaders) {
        CloseableHttpResponse resp = null;
        String url = format("%s/%s/status", format(overlordUrl, overlordHost, overlordPort), taskId);
        try {
            resp = get(url, reqHeaders);
            //TODO: Check for nulls in the following.
            JSONObject respJson = new JSONObject(IOUtils.toString(resp.getEntity().getContent()));
            JSONObject status = respJson.optJSONObject("status");
            if (status != null && null != status.getString("status")) {
                switch (status.getString("status")) {
                    case "SUCCESS":
                        return TaskStatus.SUCCESS;
                    case "RUNNING":
                        return TaskStatus.RUNNING;
                    default:
                        return TaskStatus.FAILED;
                }
            }
        } catch (IOException ex) {
            log.error("Error polling for task status {}", ExceptionUtils.getStackTrace(ex));
        } finally {
            returnClient(resp);
        }// Happens when result looks like {"task":"null"} which has no status(because such a task itself does not exist)
        return TaskStatus.UNKNOWN;
    }
206335
def CheckTaskToMerge(self, task):
    
    with self._lock:
      is_abandoned = task.identifier in self._tasks_abandoned
      is_processing = task.identifier in self._tasks_processing
      is_queued = task.identifier in self._tasks_queued

      if not is_queued and not is_processing and not is_abandoned:
        raise KeyError('Status of task {0:s} is unknown.'.format(
            task.identifier))

      return is_queued or is_processing or is_abandoned and not task.has_retry
1343866
def get_status(self, response, finished=False):
        """"""
        status_pos = 0
        for line in response.split("\n"):
            if line.startswith('JOBID'):
                try:
                    status_pos = line.find('STAT')
                except ValueError:
                    return None
            else:
                status = line[status_pos:].split()[0]
                if status in self.status_mapping:
                    return self.status_mapping[status]
        return None
943208
def report_status(self, status):
        """"""
        status = Instance('', TaskStatus).validate(None, status)
        print(r'{taskname} | {percent:>3}% | {message}'.format(
            taskname=self.__class__.__name__,
            percent=int(round(100*status.progress)),
            message=status.message if status.message else '',
        ))