Implementation \Extlib\Cron\Adapter\AdapterInterface::finishProcessing

@param \ArrayObject $jobs
@return \Extlib\Cron\Adapter\Doctrine
325359
public function finishProcessing(\ArrayObject $jobs)
    {
        foreach ($jobs as $job) {
            $job->setStatus(JobInterface::STATUS_ACTIVE);
            $job->save();
        }

        return $this;
    }
461376
protected function runJob($job, $connectorName, $maxTries, $delay)
    {
        try {
            $this->process($connectorName, $job, $maxTries, $delay);
        } catch (Exception | Throwable $e) {
            $this->handle->report($e);
        }
    }
112797
public function complete($attributes)
    {
        foreach ($this->locked as $idx => $job) {
            if ($job['id'] == $attributes['id']) {
                unset($this->locked[$idx]);
                return;
            }
        }
    }
365258
public function buildJobs($names)
    {
        foreach ($names as $name) {
            $jobInfo     = $this->config['jobs'][$name];
            $description = isset($jobInfo['description']) ? $jobInfo['description'] : "";

            $job = new JobDefinition($name, $description);
            foreach ($jobInfo['tasks'] as $taskInfo) {
                $task = new TaskDefinition($taskInfo['type']);
                $task->setContinueOnError(isset($taskInfo['continueOnError']) ? $taskInfo['continueOnError'] : false);
                unset($taskInfo['type'], $taskInfo['continueOnError']);
                $task->setParameters($taskInfo);
                $job->addTask($task);
            }
            $this->registry->addJob($job);
        }
    }
440083
protected function calculateRootJobStatus(array $jobs)
    {
        $new = 0;
        $running = 0;
        $cancelled = 0;
        $failed = 0;
        $success = 0;

        foreach ($jobs as $job) {
            switch ($job->getStatus()) {
                case Job::STATUS_NEW:
                    $new++;
                    break;
                case Job::STATUS_RUNNING:
                    $running++;
                    break;
                case Job::STATUS_CANCELLED:
                    $cancelled++;
                    break;
                case Job::STATUS_FAILED:
                    $failed++;
                    break;
                case Job::STATUS_SUCCESS:
                    $success++;
                    break;
                default:
                    throw new \LogicException(sprintf(
                        'Got unsupported job status: id: "%s" status: "%s"',
                        $job->getId(),
                        $job->getStatus()
                    ));
            }
        }

        return $this->getRootJobStatus($new, $running, $cancelled, $failed, $success);
    }
39579
public function getFinishedJobs()
    {
        while (count($this->jobs) !== 0) {
            foreach ($this->jobs as $index => $job) {
                if ($job->isFinished()) {
                    unset($this->jobs[$index]);
                    yield $index => $job;
                }
            }
        }
    }
1335977
protected function scaleDown($processes)
    {
        $difference = count($this->processes) - $processes;

        // Here we will slice off the correct number of processes that we need to terminate
        // and remove them from the active process array. We'll be adding them the array
        // of terminating processes where they'll run until they are fully terminated.
        $terminatingProcesses = array_slice(
            $this->processes, 0, $difference
        );

        collect($terminatingProcesses)->each(function ($process) {
            $this->markForTermination($process);
        })->all();

        $this->removeProcesses($difference);

        // Finally we will call the terminate method on each of the processes that need get
        // terminated so they can start terminating. Terminating is a graceful operation
        // so any jobs they are already running will finish running before these quit.
        collect($this->terminatingProcesses)
                        ->each(function ($process) {
                            $process['process']->terminate();
                        });
    }
589246
protected function workComplete(JobInterface $job)
    {
        $this->setCurrentJob(null);
        $this->getLogger()->debug('Work complete on {job}', array('job' => $job));
    }
1157496
private function runJob($job)
    {
        try {
            $this->logger->notice("Job #{$this->currentJobId} [{$job->getName()}] started.");
            $status = $this->broker->getStatus($job->getId());
            $status['status'] = Job::STATUS_RUNNING;
            $status['started'] = date(DATE_RFC3339_EXTENDED);
            $this->broker->setStatus($job->getId(), $status);
            $job->setup();
            $response = $job->go();
            $job->tearDown();
            $status['status'] = Job::STATUS_FINISHED;
            $status['finished'] = date(DATE_RFC3339_EXTENDED);
            $status['response'] = $response;
            $this->broker->setStatus($job->getId(), $status);
            $this->logger->notice("Job #{$this->currentJobId} [{$job->getName()}] finished.");
        } catch (\Exception $e) {
            $status['status'] = Job::STATUS_FAILED;
            $status['failed'] = date(DATE_RFC3339_EXTENDED);
            $this->broker->setStatus($job->getId(), $status);
            $this->logException($e, "Job #{$this->currentJobId}  [{$job->getName()}] Exception");
            $this->logger->alert("Job #{$this->currentJobId}  [{$job->getName()}] died.");
        }
    }
861110
public static function processQueueObject(Base $job)
    {
        $notification = new EmailNotification();

        if ($job->data('beforeSendCallback') !== []) {
            foreach ($job->data('beforeSendCallback') as $callback) {
                $notification->addBeforeSendCallback($callback['class'], $callback['args']);
            }
        }
        if ($job->data('afterSendCallback') !== []) {
            foreach ($job->data('afterSendCallback') as $callback) {
                $notification->addAfterSendCallback($callback['class'], $callback['args']);
            }
        }
        if ($job->data('locale') !== '') {
            $notification->locale($job->data('locale'));
        }
        $notification->unserialize($job->data('email'));

        return self::sendNotification($notification);
    }
592216
protected function processTasks($tasks)
    {
        foreach ($tasks as $taskName => $taskConfig) {
            $serviceId = sprintf('task.%s', $taskName);
            $this->container->setDefinition(
                $serviceId,
                new Definition()
            )->setSynthetic(true);

            $command = $this->buildTask($taskName, $taskConfig);

            $this->container->set($serviceId, $command);
            $this->container->get('application')->add($command);
        }
    }
657860
public function sync($jobs)
    {
        $updates = 0;

        foreach ($jobs as $job) {

            $args = $job->arguments();

            if (!isset($args[0]) || !is_scalar($args[0]) || !isset($this->tasks[$args[0]])) {
                continue;
            }

            $task = $this->tasks[$args[0]];

            $task->state = $job->state();
            $updates++;
        }

        return $updates;
    }
378384
public function doneWorking()
	{
		$this->currentJob = null;
		Resque_Stat::incr('processed');
		Resque_Stat::incr('processed:' . (string)$this);
		Resque::redis()->del('worker:' . (string)$this);
	}
1211195
public function finish(array $items = [])
    {
        foreach ($items as $item) {
            if (is_null(array_get($this->keyMap, $item))) {
                $explode = explode('.', $item);
                $this->saving($explode[0], $explode[1]);
            }
        }
        return true;
    }
141556
public function perform(JobInterface $job)
    {
        try {
            $job->perform();
        } catch (Exception $e) {
            $this->logger->notice('{job} failed: {exception}', array(
                'job'     => $job,
                'exception' => $e
            ));
            $this->failJob($job, $e);
            return;
        }

        try {
            $this->resque->getStatusFactory()->forJob($job)->update(Status::STATUS_COMPLETE);
        } catch (JobIdException $e) {
            $this->logger->warning('Could not mark job complete: no ID in payload - {exception}', array('exception' => $e));
        }

        $payload = $job->getPayload();

        $this->logger->notice('Finished job {queue}/{class} (ID: {id})', array(
            'queue' => $job->getQueue(),
            'class' => get_class($job),
            'id'    => isset($payload['id']) ? $payload['id'] : 'unknown'
        ));

        $this->logger->debug('Done with {job}', array('job' => $job));
    }
5109
public static function finishBatch($success, $results, $operations) {
    if ($success) {
      if (!empty($results['errors'])) {
        foreach ($results['errors'] as $error) {
          drupal_set_message($error, 'error');
          \Drupal::logger('config_sync')->error($error);
        }
        drupal_set_message(t('The configuration was imported with errors.'), 'warning');
      }
      else {
        drupal_set_message(t('The configuration was imported successfully.'));
      }
    }
    else {
      // An error occurred.
      // $operations contains the operations that remained unprocessed.
      $error_operation = reset($operations);
      $message = t('An error occurred while processing %error_operation with arguments: @arguments', [
        '%error_operation' => $error_operation[0],
        '@arguments' => print_r($error_operation[1], TRUE),
      ]);
      drupal_set_message($message, 'error');
    }

    $redirect_url = Url::fromRoute(self::DASHBOARD)
      ->setAbsolute()
      ->toString();
    return new RedirectResponse($redirect_url);
  }
1023561
protected function getResult(array $job, array $result = array())
    {
        $result += array(
            'done' => 0,
            'errors' => 0,
            'progress' => 0,
            'finish' => false,
            'message' => $job['message']['process']
        );

        if (!empty($result['finish'])) {
            $this->setFinishData($result, $job);
        }

        $this->setSession($job);
        return $result;
    }