Periodically checks for scheduled jobs.
8814
def scheduler(rq, ctx, verbose, burst, queue, interval, pid):
    ""
    scheduler = rq.get_scheduler(interval=interval, queue=queue)
    if pid:
        with open(os.path.expanduser(pid), 'w') as fp:
            fp.write(str(os.getpid()))
    if verbose:
        level = 'DEBUG'
    else:
        level = 'INFO'
    setup_loghandlers(level)
    scheduler.run(burst=burst)
1558
def n_waiting(self):
        """"""
        return self._counters[JobStatus.no_job] +\
            self._counters[JobStatus.unknown] +\
            self._counters[JobStatus.not_ready] +\
            self._counters[JobStatus.ready]
1333287
function () {
      var i;
      for (i = 0; i < arguments.length; i++) {
         if (!this.is_activity_scheduled(arguments[i])) {
            return false;
         }
      }
      return true;
   }
955608
function scheduleServerConnectivityChecks() {
        if (connectivityIntervalId === null) {
            connectivityIntervalId = asyncExecService.setInterval(function () {
                updateRegistrations();
                connectToServers();
            }, INTERVAL_BETWEEN_SERVER_CONNECTIVITY_CHECKS);
        }
        else {
            throw new Error("BUG ::: Attempt was made to start connectivity checks twice");
        }
    }
1116912
private boolean isScheduled(JobInProgress job) {
    return ((job.pendingMaps() < job.desiredMaps()) 
        || (job.pendingReduces() < job.desiredReduces()));
  }
421889
def verify_submit(self, job_ids, timeout, delay, **kwargs):
        """"""
        if self.skip:
            return False

        jobs = self.wait_for_jobs(job_ids, timeout, delay)
        self.get_logs(jobs, log_file=kwargs.get("log_file"))

        return self._check_outcome(jobs)
487098
public function checkQueue()
    {
        if ($this->backlog !== null) {
            while (!$this->backlog->isEmpty()) {
                if ($this->maxConcurrency !== -1 && ($this->jobsNum - $this->resultsNum > $this->maxConcurrency)) {
                    return;
                }
                list($name, $cb) = $this->backlog->shift();
                $this->addJob($name, $cb);
            }
        }
        if ($this->more !== null) {
            $this->more();
        }
    }
42803
def CheckCronJobAccess(self, username, cron_job_id):
    """"""

    self._CheckAccess(
        username, str(cron_job_id),
        rdf_objects.ApprovalRequest.ApprovalType.APPROVAL_TYPE_CRON_JOB)
49939
def _task_periodic(self):
        
        log = self._params.get('log', self._discard)
        log.debug("periodic")
        self.manage()
740616
def _IsCronJobFailing(self, cron_job):
    """"""
    status = cron_job.Get(cron_job.Schema.LAST_RUN_STATUS)
    if status is None:
      return False

    return status.status != rdf_cronjobs.CronJobRunStatus.Status.OK
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)
422690
public function scheduleWork()
    {
        if (is_null($this->scheduler)) {
            return;
        }

        $this->scheduler->reconnect();

        foreach ($this->scheduler->getJobsFor(new \DateTime()) as $job) {
            $this->pipeline->enqueue($job);
        }
    }
1031429
function () {
      var i;
      for (i = 0; i < arguments.length; i++) {
         if (!this.is_lambda_scheduled(arguments[i])) {
            return false;
         }
      }
      return true;
   }
319674
def handle_schedule(self):
        '''
        
        '''
        try:
            self.schedule.eval()
            # Check if scheduler requires lower loop interval than
            # the loop_interval setting
            if self.schedule.loop_interval < self.loop_interval:
                self.loop_interval = self.schedule.loop_interval
        except Exception as exc:
            log.error('Exception %s occurred in scheduled job', exc)
686099
def start_check (aggregate, out):
    """"""
    # check in background
    t = threading.Thread(target=director.check_urls, args=(aggregate,))
    t.start()
    # time to wait for new data
    sleep_seconds = 2
    # current running time
    run_seconds = 0
    while not aggregate.is_finished():
        yield out.get_data()
        time.sleep(sleep_seconds)
        run_seconds += sleep_seconds
        if run_seconds > MAX_REQUEST_SECONDS:
            director.abort(aggregate)
            break
    yield out.get_data()
764259
function () {
    var self = this;
    if (self._pollsScheduledButNotStarted > 0)
      return;
    ++self._pollsScheduledButNotStarted;
    self._taskQueue.queueTask(function () {
      self._pollMongo();
    });
  }
300376
public function checkRunningJobs()
    {
        $maxJobRuntime = intval(Mage::getStoreConfig(self::XML_PATH_MAX_JOB_RUNTIME));

        if ($maxJobRuntime) {
            foreach ($this->getAllRunningSchedules(gethostname()) as $schedule) { /* @var $schedule Aoe_Scheduler_Model_Schedule */
                // checking if the job isn't running too long
                if ($schedule->isAlive()) {
                    if ($schedule->getDuration() > $maxJobRuntime * 60 && !$schedule->getKillRequest()) {
                        $schedule->requestKill(null, 'Kill requested because job exceeded the max job runtime of ' . $maxJobRuntime . ' minutes.');
                    }
                }
            }
        }

        // fallback (where process cannot be checked or if one of the servers disappeared)
        // if a task wasn't seen for some time it will be marked as error
        $markAsErrorAfter = intval(Mage::getStoreConfig(self::XML_PATH_MARK_AS_ERROR));
        $maxAge = time() - min($markAsErrorAfter, 5) * 60;
        if ($markAsErrorAfter) {
            $schedules = Mage::getModel('cron/schedule')->getCollection()/* @var $schedules Mage_Cron_Model_Resource_Schedule_Collection */
            ->addFieldToFilter('status', Aoe_Scheduler_Model_Schedule::STATUS_RUNNING)
                ->addFieldToFilter('last_seen', array('lt' => strftime('%Y-%m-%d %H:%M:00', $maxAge)))
                ->load();

            foreach ($schedules as $schedule) { /* @var $schedule Aoe_Scheduler_Model_Schedule */
                // check one more time
                if ($schedule->isAlive() !== true) {
                    $schedule->markAsDisappeared(sprintf('Host "%s" has not been available for a while now to update the status of this task and the task is not reporting back by itself', $schedule->getHost()));
                    $schedule->save();
                }
            }
        }

        // clean up "running"(!?) tasks that have never been seen (for whatever reason) and have been scheduled before maxAge
        // by robinfritze. @see https://github.com/AOEpeople/Aoe_Scheduler/issues/40#issuecomment-67749476
        $schedules = Mage::getModel('cron/schedule')->getCollection() /* @var $schedules Mage_Cron_Model_Resource_Schedule_Collection */
            ->addFieldToFilter('status', Aoe_Scheduler_Model_Schedule::STATUS_RUNNING)
            ->addFieldToFilter('last_seen', array('null' => true))
            ->addFieldToFilter('host', array('null' => true))
            ->addFieldToFilter('pid', array('null' => true))
            ->addFieldToFilter('scheduled_at', array('lt' => strftime('%Y-%m-%d %H:%M:00', $maxAge)))
            ->load();

        foreach ($schedules->getIterator() as $schedule) { /* @var $schedule Aoe_Scheduler_Model_Schedule */
            $schedule->setLastSeen(strftime('%Y-%m-%d %H:%M:%S', time()));
            $schedule->markAsDisappeared(sprintf('Process "%s" (id: %s) cannot be found anymore', $schedule->getJobCode(), $schedule->getId()));
        }

    }