Return the number of jobs in various waiting states
1558
def n_waiting(self):
        """"""
        return self._counters[JobStatus.no_job] +\
            self._counters[JobStatus.unknown] +\
            self._counters[JobStatus.not_ready] +\
            self._counters[JobStatus.ready]
105818
def get_jobs():
    """"""

    jobs = current_app.apscheduler.get_jobs()

    job_states = []

    for job in jobs:
        job_states.append(job)

    return jsonify(job_states)
1329746
def returnJobReqs(self, jobReqs):
        
        # Since we are only reading this job's specific values from the state file, we don't
        # need a lock
        jobState = self._JobState(self._CacheState._load(self.cacheStateFile
                                                         ).jobState[self.jobID])
        for x in list(jobState.jobSpecificFiles.keys()):
            self.deleteLocalFile(x)
        with self._CacheState.open(self) as cacheInfo:
            cacheInfo.sigmaJob -= jobReqs
1087172
def running?
      total_jobs_running = get_jobs_by_status(Executor::STATUS_NONE).size +
                           get_jobs_by_status(Executor::STATUS_RUNNING).size +
                           get_jobs_by_status(Executor::STATUS_RETRYING).size
      (total_jobs_running > 0)
    end
47875
def get_active_queue(self):
        """"""

        # Get dict of active queues keyed by name
        queues = {q['jobQueueName']: q for q in self._client.describe_job_queues()['jobQueues']
                  if q['state'] == 'ENABLED' and q['status'] == 'VALID'}
        if not queues:
            raise Exception('No job queues with state=ENABLED and status=VALID')

        # Pick the first queue as default
        return list(queues.keys())[0]
497903
def list(self, search_opts=None, limit=None,
             marker=None, sort_by=None, reverse=None):
        """"""
        query = base.get_query_string(search_opts, limit=limit, marker=marker,
                                      sort_by=sort_by, reverse=reverse)
        url = "/jobs%s" % query
        return self._page(url, 'jobs', limit)
132591
def done?
      return (
        get_jobs_by_status(Executor::STATUS_NONE).size == 0 &&
        get_jobs_by_status(Executor::STATUS_RUNNING).size == 0 &&
        get_jobs_by_status(Executor::STATUS_DONE).size > 0
      )
    end
1128942
def extract_submittable_jobs(waiting):
    
    submittable = set()            # Holds jobs that are able to be submitted
    # Loop over each job, and check all the subjobs in that job's dependency
    # list.  If there are any, and all of these have been submitted, then
    # append the job to the list of submittable jobs.
    for job in waiting:
        unsatisfied = sum([(subjob.submitted is False) for subjob in
                           job.dependencies])
        if unsatisfied == 0:
            submittable.add(job)
    return list(submittable)
369884
def job_count_enabled(self):
		
		enabled = 0
		for job_desc in self._jobs.values():
			if job_desc['enabled']:
				enabled += 1
		return enabled
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)
746888
public JobResult waitForJobState(String jobname, CrawlControllerState state, int tries, int interval) {
        JobResult jobResult = null;
        if (tries <= 0) {
            tries = 1;
        }
        if (interval <= 99) {
            interval = 1000;
        }
        boolean bLoop = true;
        while (bLoop && tries > 0) {
            jobResult = job(jobname);
            // debug
            //System.out.println(jobResult.status + " - " + ResultStatus.OK);
            if (jobResult.status == ResultStatus.OK) {
                // debug
                //System.out.println(jobResult.job.crawlControllerState + " - " + state.name());
                if ((state == null && jobResult.job.crawlControllerState == null) || (state != null && state.name().equals(jobResult.job.crawlControllerState))) {
                    bLoop = false;
                }
            }
            --tries;
            if (bLoop && tries > 0) {
                try {
                    Thread.sleep(interval);
                } catch (InterruptedException e) {
                }
            }
        }
        return jobResult;
    }
1276986
def divide(cls, jobs, count):
        ''''''
        jobs = list(zip(*zip_longest(*[iter(jobs)] * count)))
        # If we had no jobs to resume, then we get an empty list
        jobs = jobs or [()] * count
        for index in range(count):
            # Filter out the items in jobs that are Nones
            jobs[index] = [j for j in jobs[index] if j != None]
        return jobs
334615
def find_jobs(self, job_ids):
        """"""
        matched_jobs = []
        if self.skip:
            return matched_jobs

        json_data = self.download_queue(job_ids)
        if not json_data:
            return matched_jobs

        jobs = json_data["jobs"]
        for job in jobs:
            if (
                job.get("id") in job_ids
                and job.get("status", "").lower() not in _NOT_FINISHED_STATUSES
            ):
                matched_jobs.append(job)

        return matched_jobs
1303624
def getNextJobID(self):  # type: () -> int
        
        with self.localBatch.jobIndexLock:
            jobID = self.localBatch.jobIndex
            self.localBatch.jobIndex += 1
        return jobID
820252
def job_status(self, project, job_id):
        
        all_jobs = self.list_jobs(project)
        for state in constants.JOB_STATES:
            job_ids = [job['id'] for job in all_jobs[state]]
            if job_id in job_ids:
                return state
        return ''
1304245
private List<Job> getJobs(final Jedis jedis, final String queueName, final long jobOffset, final long jobCount) throws Exception {
        final String key = key(QUEUE, queueName);
        final List<Job> jobs = new ArrayList<>();
        if (JedisUtils.isDelayedQueue(jedis, key)) { // If delayed queue, use ZRANGEWITHSCORES
            final Set<Tuple> elements = jedis.zrangeWithScores(key, jobOffset, jobOffset + jobCount - 1);
            for (final Tuple elementWithScore : elements) {
                final Job job = ObjectMapperFactory.get().readValue(elementWithScore.getElement(), Job.class);
                job.setRunAt(elementWithScore.getScore());
                jobs.add(job);
            }
        } else { // Else, use LRANGE
            final List<String> elements = jedis.lrange(key, jobOffset, jobOffset + jobCount - 1);
            for (final String element : elements) {
                jobs.add(ObjectMapperFactory.get().readValue(element, Job.class));
            }
        }
        return jobs;
    }
1249898
def _status(self):
        ''' 
        '''

        job_id_list = ' '.join(self.resources.keys())

        jobs_missing = list(self.resources.keys())

        retcode, stdout, stderr = self.channel.execute_wait("qstat {0}".format(job_id_list), 3)
        for line in stdout.split('\n'):
            parts = line.split()
            if not parts or parts[0].upper().startswith('JOB') or parts[0].startswith('---'):
                continue
            job_id = parts[0]
            status = translate_table.get(parts[4], 'UNKNOWN')
            self.resources[job_id]['status'] = status
            jobs_missing.remove(job_id)

        # squeue does not report on jobs that are not running. So we are filling in the
        # blanks for missing jobs, we might lose some information about why the jobs failed.
        for missing_job in jobs_missing:
            if self.resources[missing_job]['status'] in ['PENDING', 'RUNNING']:
                self.resources[missing_job]['status'] = translate_table['E']