Handle a single job and/or schedule. Unblocks at least after 60 seconds.

@return null
427037
public function process()
    {
        pcntl_signal_dispatch();

        try {
            $read = $write = array();
            $timeout = $this->calculatePollTimeout();
            $this->getPoller()->poll($read, $write, $timeout);
        } catch (\ZMQPollException $ex) {
            pcntl_signal_dispatch();
            $this->getLogger()->debug('[SERVICE] Received Poll Exception: '.$ex->getMessage().'('.$ex->getCode().')');

            return;
        }

        $this->stream->handle();
        $this->runSchedule();
    }
85526
public function wait(): Process
    {
        $cursor = $this->events->getCursor([
            'job' => $this->getId(),
            'status' => ['$gte' => JobInterface::STATUS_DONE],
        ]);

        while (true) {
            if (null === $cursor->current()) {
                if ($cursor->getInnerIterator()->isDead()) {
                    $this->events->create();

                    return $this->wait();
                }

                $this->events->next($cursor, function () {
                    $this->wait();
                });

                continue;
            }

            $event = $cursor->current();
            $this->events->next($cursor, function () {
                $this->wait();
            });

            $this->job['status'] = $event['status'];

            if (JobInterface::STATUS_FAILED === $this->job['status'] && isset($event['exception'])) {
                throw new $event['exception']['class'](
                    $event['exception']['message'],
                    $event['exception']['code']
                );
            }

            return $this;
        }
    }
188599
public function handle()
    {
        $events = $this->scheduleList->all();

        if (count($events) === 0) {
            $this->info('No tasks scheduled');
            return;
        }

        if ($this->option('cron')) {
            $this->outputCronStyle($events);
            return;
        }

        $this->outputTableStyle($events);
    }
902519
public function onReady()
    {
        $this->redis = \PHPDaemon\Clients\Redis\Pool::getInstance();

        $this->redis->multi(function ($multi) {
            // "OK"
            D('start multi: ' . $multi->result);

            $multi->set('test1', 'value1', function ($redis) use ($multi) {
                // "QUEUED"
                D('in multi 1: ' . $redis->result);

                $this->redis->set('test1', 'value1-new', function ($redis) {
                    // "OK", not "QUEUED"
                    D('out multi 1: ' . $redis->result);
                });

                setTimeout(function ($timer) use ($multi) {
                    // "QUEUED"
                    $multi->set('test2', 'value2', function ($redis) use ($multi) {
                        D('in multi 2: ' . $redis->result);

                        $multi->exec(function ($redis) {
                            D('exec');
                            D($redis->result);
                        });
                    });
                    $timer->free();
                }, 2e5);
            });
        });
    }
331411
public function handle_cron_healthcheck() {
		if ( $this->is_process_running() ) {
			// Background process already running.
			exit;
		}

		if ( $this->is_queue_empty() ) {
			// No data to process.
			$this->clear_scheduled_event();
			exit;
		}

		$this->handle();

		exit;
	}
1098613
private function getNextCronJob(): ?Job
    {
        $cron_id = $this->getNextCronId();

        if (is_null($cron_id)) {
            return null;
        }

        $key = sprintf('%s:%s', self::CRON_QUEUE_NAME, $cron_id);

        $data = json_decode($this->client->get($key), true);

        $this->updateCron($cron_id, $data['cron']);

        $job = $data['job'];

        return new Job($job['class'], $job['queue'], $job['args']);
    }
378384
public function doneWorking()
	{
		$this->currentJob = null;
		Resque_Stat::incr('processed');
		Resque_Stat::incr('processed:' . (string)$this);
		Resque::redis()->del('worker:' . (string)$this);
	}
518055
public function handle()
    {
        foreach ($this->getJobIds() as $id) {
            $job = $this->laravel['queue.failer']->find($id);

            if (is_null($job)) {
                $this->error("Unable to find failed job with ID [{$id}].");
            } else {
                $this->retryJob($job);

                $this->info("The failed job [{$id}] has been pushed back onto the queue!");

                $this->laravel['queue.failer']->forget($id);
            }
        }
    }
535860
protected function processLocalQueue(): self
    {
        foreach ($this->onhold as $id => $job) {
            if ($job['options']['at'] <= time() && ($this->count() < $this->max_children || true === $job['options']['force_spawn'])) {
                $this->logger->debug('hold ondemand job ['.$id.'] may no be executed', [
                    'category' => get_class($this),
                ]);

                unset($this->onhold[$id]);
                $this->spawnWorker($job['_id']);
            }
        }

        return $this;
    }
648952
public function work($interval = self::DEFAULT_INTERVAL, $blocking = false)
    {
        if ($interval !== null) {
            $this->interval = $interval;
        }

        $this->updateProcLine('Starting');
        $this->startup();

        while (true) {
            if (function_exists('pcntl_signal_dispatch')) {
                pcntl_signal_dispatch();
            }
            if ($this->shutdown) {
                break;
            }
            if (!$this->paused) {
                /** Handle delayed items for the next scheduled timestamp. */
                $this->handleDelayedItems(null);
            } else {
                $this->updateProcLine('Paused');
            }
            $this->updateProcLine('Waiting for new jobs');
            sleep($this->interval);
        }

        $this->unregisterWorker();
    }
1329701
public function runNowAction()
    {
        $code = $this->getArg('code');
        if (empty($code)) {
            echo "\nNo code found!\n\n";
            echo $this->usageHelp();
            exit(1);
        }

        $allowedCodes = Mage::getSingleton('aoe_scheduler/job')->getResource()->getJobCodes();
        if (!in_array($code, $allowedCodes)) {
            echo "\nNo valid job found!\n\n";
            echo $this->usageHelp();
            exit(1);
        }

        $forceRun = ($this->getArg('force'));
        $tryLock = ($this->getArg('tryLock'));

        $schedule = Mage::getModel('cron/schedule'); /* @var $schedule Aoe_Scheduler_Model_Schedule */
        $schedule->setJobCode($code);
        $schedule->setScheduledReason(Aoe_Scheduler_Model_Schedule::REASON_RUNNOW_CLI);
        $schedule->runNow($tryLock, $forceRun);
        if ($schedule->getJobWasLocked()) {
            echo "\nJob was not executed because it was locked!\n\n";
            exit(1);
        }
        $schedule->save();

        echo "\nStatus: " . $schedule->getStatus() . "\n";
        echo "Messages:\n" . trim($schedule->getMessages(), "\n") . "\n";
    }
181157
protected function handle() {
		$this->lock_process();

		$shouldCancelAll = false;

		do {
			$batch = $this->get_batch();

			if ((count($batch->data) == 0) || (!$this->shouldHandle())) {
				$shouldCancelAll = true;
				Logger::info( "No batch to process", $batch);
				break;
			}

			Logger::info( "Processing Batch", $batch->data);
			foreach ( $batch->data as $key => $value ) {
				if ($this->shouldHandle()) {
					Logger::info( "Running task", $value);

					$task = $this->task( $value );

					if ( false !== $task ) {
						$batch->data[ $key ] = $task;
					} else {
						unset( $batch->data[ $key ] );
					}

					if ( $this->time_exceeded() || $this->memory_exceeded() ) {
						// Batch limits reached.
						break;
					}
				}
			}

			// Update or delete current batch.
			if ( ! empty( $batch->data ) ) {
				$this->update( $batch->key, $batch->data );
			} else {
				$this->delete( $batch->key );
			}
		} while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() );

		$this->unlock_process();

		if ($shouldCancelAll) {
			$this->complete();
			static::cancelAll();
		} else {
			if ( ! $this->is_queue_empty() ) {
				$this->dispatch();
			} else {
				$this->complete();
			}
		}

		wp_die();
	}
622287
public function process()
    {
        foreach ($this->jobs as $id => $job) {
            // process the job
            $this->resolveJob($job['job'], json_encode($job['data']))->fire();
            // remove it from the processing queue
            unset($this->jobs[$id]);
        }
    }
198790
public function handle()
    {
        return $this->dbTransaction(function () {
            $lastAction = $this->block->restore();

            event('block.restored', [$this->block]);

            return $lastAction;
        });
    }
1295084
private function handle(){
        $params = [
            "start"     => null,
            "finish"    => null,
            "response"  => null,
            "error"     => null,
        ];

        try{
            $params["start"]    = microtime(true);
            $params["response"] = $this->handler->handle($this->request);
        }catch(\Throwable $e){
            $params["error"]    = $e;
            $this->error        = $e;
        }finally{
            $params["finish"]   = microtime(true);
        }

        $this->event(new Event("response.handle.after", $params));

        return $params["response"];
    }
876944
public function doneWorking()
    {
        $this->currentJob = null;
        $this->resque->getStatistic('processed')->incr();
        $this->getStatistic('processed')->incr();
        $this->resque->getClient()->del($this->getJobKey());
    }
894334
public function handle()
    {
        collect($this->schedule->events())->filter(function ($value) {
            return $value->mutexName() == $this->argument('id');
        })->each->callAfterCallbacks($this->laravel);
    }