Return a batch of jobs that are next in line to be executed.

@param  int            $jobs_to_run
@param  string[]       ...$from_channels
@return JobInterface[]
330949
public function nextBatchInLine($jobs_to_run, ...$from_channels)
    {
        if (!is_int($jobs_to_run)) {
            if (ctype_digit($jobs_to_run)) {
                $jobs_to_run = (int) $jobs_to_run;
            } else {
                throw new InvalidArgumentException('Jobs to run needs to be a number larger than zero');
            }
        }

        if ($jobs_to_run < 1) {
            throw new InvalidArgumentException('Jobs to run needs to be a number larger than zero');
        }

        $result = [];

        foreach ($this->reserveNextJobs($from_channels, $jobs_to_run) as $job_id) {
            $result[] = $this->getJobById($job_id);
        }

        return $result;
    }
212350
def get_jobs_from_queue(self, queue: str, max_jobs: int) -> List[Job]:
        """"""
        jobs_json_string = self._run_script(
            self._get_jobs_from_queue,
            self._to_namespaced(queue),
            self._to_namespaced(RUNNING_JOBS_KEY.format(self._id)),
            JobStatus.RUNNING.value,
            max_jobs
        )

        jobs = json.loads(jobs_json_string.decode())
        jobs = [Job.deserialize(job) for job in jobs]

        return jobs
578353
protected function findNextJob(): ?Job
    {
        $next_at_timestamp = $this->getNextAtTimestamp();
        $cron_id = $this->getNextCronId();

        if (is_null($cron_id)) {
            return $this->getNextAtJob();
        }

        $next_cron_timestamp = $this->getCronTimestamp($cron_id);

        if ($next_at_timestamp <= $next_cron_timestamp) {
            return $this->getNextAtJob();
        }

        return $this->getNextCronJob();
    }
626278
public function runMultiple(array $statements)
    {
        $pipeline = $this->session->createPipeline();

        foreach ($statements as $statement) {
            $pipeline->push($statement->text(), $statement->parameters(), $statement->getTag());
        }

        return $pipeline->run();
    }
317674
public static function getList($scheduledOnly = false)
    {
        $db = Loader::db();

        if ($scheduledOnly) {
            $q = "SELECT jID FROM Jobs WHERE isScheduled = 1 ORDER BY jDateLastRun, jID";
        } else {
            $q = "SELECT jID FROM Jobs ORDER BY jDateLastRun, jID";
        }
        $r = $db->Execute($q);
        $jobs = array();
        while ($row = $r->FetchRow()) {
            $j = static::getByID($row['jID']);
            if (is_object($j)) {
                $jobs[] = $j;
            }
        }

        return $jobs;
    }
1084366
public function toArray()
    {
        $jobs = array();

        foreach ($this->workerJobs as $job) {

            $jobs[] = $job->toArray();
        }

        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
876421
public function migrateExpiredJobs($from, $to)
	{
		$jobs = $this->getExpiredJobs($from, $time = $this->getTime());

		if (count($jobs) > 0)
		{
			$this->removeExpiredJobs($from, $time);

			call_user_func_array(array($this->redis, 'rpush'), array_merge(array($to), $jobs));
		}
	}
254508
void selectJobsToInitialize() {
    for (String queue : jobQueues.keySet()) {
      ArrayList<JobInProgress> jobsToInitialize = getJobsToInitialize(queue);
      printJobs(jobsToInitialize);
      JobInitializationThread t = threadsToQueueMap.get(queue);
      for (JobInProgress job : jobsToInitialize) {
        t.addJobsToQueue(queue, job);
      }
    }
  }
1091252
protected function getCallables(
        /*# string */ $type,
        /*# string */ $channel
    )/*# : PriorityQueue */ {

        // name globbing with all channels
        $matchedChannels = $this->globbingNames(
            $channel,
            $this->getAllChannels($type)
        );

        // type queues
        $q = &$this->$type;

        // merge queues
        $queue = new PriorityQueue();
        foreach ($matchedChannels as $c) {
            $queue = $queue->combine($q[$c]);
        }

        return $queue;
    }
228139
private function loadPerformedMigrations($batch)
    {
        $migrations = [];

        $pluginMigrations = $this->pluginMigrations();

        /** @noinspection SqlDialectInspection */
        $rows = $this->db->table('_migrations')->select('name')->whereCondition('batch = ?', [$batch])->all();
        foreach ($rows as $row) {
            $name = $row['name'];
            $migrations[$name] = isset($pluginMigrations[$name]) ? $pluginMigrations[$name] : $this->migrationPath . DIRECTORY_SEPARATOR . $name . '.php';
        }

        return $migrations;
    }
1326697
protected function runNextJobForDaemon($connectionName, $queue, $delay, $sleep, $maxTries)
	{
		try
		{
			$this->pop($connectionName, $queue, $delay, $sleep, $maxTries);
		}
		catch (Exception $e)
		{
			if ($this->exceptions) $this->exceptions->report($e);
		}
	}
24236
public function migrateExpiredJobs($from, $to)
    {
        return tap(parent::migrateExpiredJobs($from, $to), function ($jobs) use ($to) {
            $this->event($to, new JobsMigrated($jobs));
        });
    }
891188
public function getJobList()
    {
        $propertyList = $this->_getEntityList('Jobs');
        $result = [];

        foreach ($propertyList as $properties) {
            $result[] = Job::createFromOptions($properties);
        }

        return $result;
    }
416702
public function getNextJob()
    {
        $jobInfo = $this->broker->get();

        if (!class_exists($jobInfo['class'])) {
            $this->logger->error("Class {$jobInfo['class']} for scheduled job not found");
            return false;
        }

        $job = unserialize($jobInfo['object']);

        if (is_object($job) && is_a($job, '\ajumamoro\Job')) {
            $job->setId($jobInfo['id']);
            return $job;
        } else {
            $this->logger->error("Scheduled job is not of type \\ajumamoro\\Job");
            return false;
        }
    }
922375
protected function makeRequest($jobs)
    {
        foreach ($this->plugins as $plugin) {
            $plugin->willSendRequest($jobs);
        }

        $response = $this->doRequest($jobs);
        return $this->finalize($response);
    }
883224
public function requestJob()
    {
        $findCond = [
            'conditions' => [
                'completed' => 0
            ],
            'order' => [
                'created ASC',
                'id ASC',
            ],
            'limit' => 3,
        ];

        $jobs = $this->find('all', $findCond)->all()->toArray();
        for ($i=0; $i<count($jobs); $i++) {
            if ($jobs[$i]['stats']['tries'] >= $this->maxTries) {
                unset($jobs[$i]);
            }
        }
        return $jobs;
    }