Add a "pending" result that we expect to get results for.

        :param ps: the parameters for the result
        :param jobid: an identifier for the pending result
547566
def addPendingResult( self, ps, jobid ):
        """"""
        k = self._parametersAsIndex(ps)

        # retrieve or create the result list
        if k in self._results.keys():
            rs = self._results[k]
        else:
            rs = []
            self._results[k] = rs

        # append the pending result's jobid
        rs.insert(0, jobid)

        # map job id to parameters to which it refers
        self._pending[jobid] = k
160847
synchronized public String addJob(Job aJob) {
    String id = this.getNextJobID();
    aJob.setJobID(id);
    aJob.setState(Job.WAITING);
    this.addToQueue(aJob);
    return id;	
  }
1273881
function PendingJob(worker, id, resolve, reject) {
  this.worker = worker;
  this.id = id;
  this.job = co.job(resolve, reject);
  this.timer = null;
}
464798
def pending_work_items(self):
        ""
        pending = self._conn.execute(
            "SELECT * FROM work_items WHERE job_id NOT IN (SELECT job_id FROM results)"
        )
        return (_row_to_work_item(p) for p in pending)
625903
def apps_installations_job_status_show(self, id, **kwargs):
        ""
        api_path = "/api/v2/apps/installations/job_statuses/{id}.json"
        api_path = api_path.format(id=id)
        return self.call(api_path, **kwargs)
658547
def job_success(self, job, queue, job_result):
        
        job.queued.delete()
        job.hmset(end=str(datetime.utcnow()), status=STATUSES.SUCCESS)
        queue.success.rpush(job.ident)
        self.log(self.job_success_message(job, queue, job_result))
        if hasattr(job, 'on_success'):
            job.on_success(queue, job_result)
1237844
def job_success(self, job, queue, job_result):
        

        # display what was done
        obj = job.get_object()
        message = '[%s|%s] %s [%s]' % (queue.name.hget(),
                                       obj.pk.get(),
                                       job_result,
                                       threading.current_thread().name)
        self.log(message)

        # default stuff: update job and queue statuses, and do logging
        super(FullNameWorker, self).job_success(job, queue, job_result)

        # update the queue's dates
        queue_fields_to_update = {
            'last_job_date': str(datetime.utcnow())
        }
        if not queue.first_job_date.hget():
            queue_fields_to_update['first_job_date'] = queue_fields_to_update['last_job_date']
        queue.hmset(**queue_fields_to_update)

        # update the jobs counter on the queue
        queue.jobs_counter.hincrby(1)

        # save a ref to the job to display at the end of this example script
        self.jobs.append(int(job.pk.get()))
1212193
def wait_on_job(self, job_id):
        """"""

        while True:
            status = self.get_job_status(job_id)
            if status == 'SUCCEEDED':
                logger.info('Batch job {} SUCCEEDED'.format(job_id))
                return True
            elif status == 'FAILED':
                # Raise and notify if job failed
                jobs = self._client.describe_jobs(jobs=[job_id])['jobs']
                job_str = json.dumps(jobs, indent=4)
                logger.debug('Job details:\n' + job_str)

                log_stream_name = jobs[0]['attempts'][0]['container']['logStreamName']
                logs = self.get_logs(log_stream_name)
                raise BatchJobException('Job {} failed: {}'.format(
                    job_id, logs))

            time.sleep(self.poll_time)
            logger.debug('Batch job status for job {0}: {1}'.format(
                job_id, status))
303068
def add_job_to_db(self, key, job):
        """"""
        job_msg = self.registry.deep_encode(job)
        prov = prov_key(job_msg)

        def set_link(duplicate_id):
            self.cur.execute(
                'update "jobs" set "link" = ?, "status" = ? where "id" = ?',
                (duplicate_id, Status.DUPLICATE, key))

        with self.lock:
            self.cur.execute(
                'select * from "jobs" where "prov" = ? '
                'and (("result" is not null) or '
                '("session" = ? and "link" is null))',
                (prov, self.session))
            rec = self.cur.fetchone()
            rec = JobEntry(*rec) if rec is not None else None

            self.cur.execute(
                'update "jobs" set "prov" = ?, "version" = ?, "function" = ?, '
                '"arguments" = ?, "status" = ? where "id" = ?',
                (prov, job_msg['data']['hints'].get('version'),
                 json.dumps(job_msg['data']['function']),
                 json.dumps(job_msg['data']['arguments']),
                 Status.WAITING,
                 key))

            if not rec:
                # no duplicate found, go on
                return 'initialized', None

            set_link(rec.id)

            if rec.result is not None and rec.status == Status.WORKFLOW:
                # the found duplicate returned a workflow
                if rec.link is not None:
                    # link is set, so result is fully realized
                    self.cur.execute(
                        'select * from "jobs" where "id" = ?',
                        (rec.link,))
                    rec = self.cur.fetchone()
                    assert rec is not None, "database integrity violation"
                    rec = JobEntry(*rec)

                else:
                    # link is not set, the result is still waited upon
                    assert rec.session == self.session, \
                        "database integrity violation"
                    self.attached[rec.id].append(key)
                    return 'attached', None

            if rec.result is not None:
                # result is found! return it
                result_value = self.registry.from_json(rec.result, deref=True)
                result = ResultMessage(
                    key, 'retrieved', result_value, None)
                return 'retrieved', result

            if rec.session == self.session:
                # still waiting for result, attach
                self.attached[rec.id].append(key)
                return 'attached', None
356715
public synchronized void notifyTaskCompletion(long jobId, int taskId, Object result) {
    Pair<Long, Integer> id = new Pair<>(jobId, taskId);
    TaskInfo.Builder taskInfo = mUnfinishedTasks.get(id);
    taskInfo.setStatus(Status.COMPLETED);
    try {
      taskInfo.setResult(ByteString.copyFrom(SerializationUtils.serialize(result)));
    } catch (IOException e) {
      // TODO(yupeng) better error handling
      LOG.warn("Failed to serialize {} : {}", result, e.getMessage());
      LOG.debug("Exception: ", e);
    } finally {
      finishTask(id);
      LOG.info("Task {} for job {} completed.", taskId, jobId);
    }
  }
436485
def get_batch_result(self, job_id, batch_id, result_id):
        
        response = requests.get(self._get_batch_result_url(job_id, batch_id, result_id),
                                headers=self._get_session_headers())
        response.raise_for_status()

        return response.content
1077701
def refresh(self):
    """"""
    if self.status == 'executing' and self.array:
      new_result = 0
      for array_job in self.array:
        if array_job.status == 'failure' and new_result is not None:
          new_result = array_job.result
        elif array_job.status not in ('success', 'failure'):
          new_result = None
      if new_result is not None:
        self.status = 'success' if new_result == 0 else 'failure'
        self.result = new_result
1304089
def wait_for_job(self):
        
        blpop_result = self.connection.blpop(self.keys, self.timeout)
        if blpop_result is None:
            return None
        queue_redis_key, job_ident = blpop_result
        self.set_status('running')
        return self.get_queue(queue_redis_key), self.get_job(job_ident)
1194216
def _get_job_results(query=None):
    '''
    
    '''
    if not query:
        raise CommandExecutionError("Query parameters cannot be empty.")

    response = __proxy__['panos.call'](query)

    # If the response contains a job, we will wait for the results
    if 'result' in response and 'job' in response['result']:
        jid = response['result']['job']

        while get_job(jid)['result']['job']['status'] != 'FIN':
            time.sleep(5)

        return get_job(jid)
    else:
        return response
1180834
async def result_info(self) -> Optional[JobResult]:
        
        v = await self._redis.get(result_key_prefix + self.job_id, encoding=None)
        if v:
            return unpickle_result(v)
406694
def get_results(self, job_id):
        
        url = self._url('%s/results' % job_id)
        return self.client.get(url)
409617
def _processReadyJobs(self):
        """"""
        logger.debug('Built the jobs list, currently have %i jobs to update and %i jobs issued',
                     len(self.toilState.updatedJobs), self.getNumberOfJobsIssued())

        updatedJobs = self.toilState.updatedJobs # The updated jobs to consider below
        self.toilState.updatedJobs = set() # Resetting the list for the next set

        for jobGraph, resultStatus in updatedJobs:
            self._processReadyJob(jobGraph, resultStatus)