Finds the jobs in the completed job queue.
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
516536
function completeJob(loader, job, callback) {
    var nextJob;

    loader.jobsInProgress--;

    if ((!loader.jobLimit || loader.jobsInProgress < loader.jobLimit) && loader.jobQueue.length > 0) {
        nextJob = loader.jobQueue.shift();
        nextJob.start();
        loader.jobsInProgress++;
    }

    callback(job.image, job.errorMsg, job.request);
}
738376
def results(self):
        ""
        cur = self._conn.cursor()
        rows = cur.execute("SELECT * FROM results")
        for row in rows:
            yield (row['job_id'], _row_to_work_result(row))
1154932
def get_jobs_from_queue(self, queue: str, max_jobs: int) -> List[Job]:
        """"""
        rv = list()
        while len(rv) < max_jobs:
            try:
                job_json_string = self._get_queue(queue).get(block=False)
            except Empty:
                break

            job = Job.deserialize(job_json_string)
            job.status = JobStatus.RUNNING
            rv.append(job)

        return rv
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
820453
def enqueue_jobs(self):
        
        self.log.debug('Checking for scheduled jobs')

        jobs = self.get_jobs_to_queue()
        for job in jobs:
            self.enqueue_job(job)

        # Refresh scheduler key's expiry
        self.connection.expire(self.scheduler_key, int(self._interval) + 10)
        return jobs
783567
def get_jobs(self, recursive=True):
        
        if recursive:
            ret_dict = self.jobs.copy()
            ret_dict.update(self._scatter_link.get_jobs(recursive))
            return ret_dict
        return self.jobs
370049
def jobs(self):
        
        jobs = list()
        for data in self.data.jobs:
            jobs.append(JobInstance(session=self._session, data=data, stage=self))

        return jobs
31714
def jobs(opts={})

      opts = { opts => true } if opts.is_a?(Symbol)

      jobs = @jobs.to_a

      if opts[:running]
        jobs = jobs.select { |j| j.running? }
      elsif ! opts[:all]
        jobs = jobs.reject { |j| j.next_time.nil? || j.unscheduled_at }
      end

      tags = Array(opts[:tag] || opts[:tags]).collect(&:to_s)
      jobs = jobs.reject { |j| tags.find { |t| ! j.tags.include?(t) } }

      jobs
    end
635839
def _on_completion(self):
        

        logger.debug('Job {0} running _on_completion check'.format(self.name))
        if self.state.status != 'running' or (not self._is_complete()):
            return

        for job, results in self.run_log['tasks'].iteritems():
            if results.get('success', False) == False:
                self._set_status('failed')
                try:
                    self.backend.acquire_lock()
                    if self.event_handler:
                        self.event_handler.emit('job_failed',
                                                self._serialize(include_run_logs=True))
                except:
                    logger.exception("Error in handling events.")
                finally:
                    self.backend.release_lock()
                break

        if self.state.status != 'failed':
            self._set_status('waiting')
            self.run_log = {}
            try:
                self.backend.acquire_lock()
                if self.event_handler:
                    self.event_handler.emit('job_complete',
                                            self._serialize(include_run_logs=True))
            except:
                logger.exception("Error in handling events.")
            finally:
                self.backend.release_lock()

        self.destroy_snapshot()
61616
def _load_jobs(self):
        
        jobs = self.app.config.get('SCHEDULER_JOBS')

        if not jobs:
            jobs = self.app.config.get('JOBS')

        if jobs:
            for job in jobs:
                self.add_job(**job)
114032
function readQueue() {
        disq.getJob({queue: queueName, count: self.jobCount, withcounters: self.withCounters}, function(err, jobs) {
            if(err) {
                self.emit('error', err);
            }
            else {
                jobs.forEach(function(job) {
                    pendingMessages++;
                    self.emit('job', job, function() {
                        pendingMessages--;
                        if(!self.paused && concurrencyPaused && pendingMessages < self.concurrency) {
                            concurrencyPaused = false;
                            setImmediate(readQueue);
                        }
                    });
                });

                if(!self.paused && pendingMessages<self.concurrency) {
                    setImmediate(readQueue);
                }
                else {
                    concurrencyPaused = true;
                }
            }
        });
    }
466192
function(job, done) {
                    Async.whilst(
                        function() { return !job.properties().isDone; },
                        function(iterationDone) {
                            job.fetch(function(err, job) {
                                if (err) {
                                    callback(err);
                                }
                                else {
                                    // If the user asked for verbose output,
                                    // then write out the status of the search
                                    var properties = job.properties();
                                    if (isVerbose) {
                                        var progress    = (properties.doneProgress * 100.0) + "%";
                                        var scanned     = properties.scanCount;
                                        var matched     = properties.eventCount;
                                        var results     = properties.resultCount;
                                        var stats = "-- " +
                                            progress + " done | " +
                                            scanned  + " scanned | " +
                                            matched  + " matched | " +
                                            results  + " results";
                                        print("\r" + stats + "                                          ");
                                    }
                                    
                                    Async.sleep(1000, iterationDone);
                                }
                            });
                        },
                        function(err) {
                            if (isVerbose) {
                                print("\r");
                            }
                            done(err, job);
                        }
                    );
                }
600646
public java.util.List<Job> getJobs() {
        if (jobs == null) {
            jobs = new com.amazonaws.internal.SdkInternalList<Job>();
        }
        return jobs;
    }
185185
def _obtain_queue(num_jobs):
    
    if _should_use_multiprocessing(num_jobs):
        return ReprQueue(multiprocessing.Manager().Queue())

    return ReprQueue(Queue())
158306
def jobs(self):
        ''''''
        # If we should resume work, then we should hand those out first,
        # assuming we can still heartbeat them
        for job in self.resume:
            try:
                if job.heartbeat():
                    yield job
            except exceptions.LostLockException:
                logger.exception('Cannot resume %s' % job.jid)
        while True:
            seen = False
            for queue in self.queues:
                job = queue.pop()
                if job:
                    seen = True
                    yield job
            if not seen:
                yield None
664702
def run_jobs(delete_completed=False, ignore_errors=False, now=None):
    
    if ScheduledJob.objects.filter(status='running'):
        raise ValueError('jobs in progress found; aborting')
    if now is None:
        now = datetime.datetime.now()

    expire_jobs(now)
    schedule_sticky_jobs()
    start_scheduled_jobs(now, delete_completed, ignore_errors)