Refactor DaemonRun::afterProcess for better readability
[MAILPOET-4684]
This commit is contained in:
committed by
Aschepikov
parent
de22257af3
commit
9c0ce5ed7a
@@ -85,17 +85,21 @@ class DaemonRun {
|
|||||||
* After Action Scheduler finishes its work we need to check if there is more work and in case there is we trigger additional runner.
|
* After Action Scheduler finishes its work we need to check if there is more work and in case there is we trigger additional runner.
|
||||||
*/
|
*/
|
||||||
public function afterProcess(): void {
|
public function afterProcess(): void {
|
||||||
$lastDurationWasTooShort = ($this->lastRunDuration < self::SHORT_DURATION_THRESHOLD) && ($this->remainingExecutionLimit > 0);
|
$hasJobsToDo = $this->wordpressTrigger->checkExecutionRequirements();
|
||||||
// Schedule next action in case we have more jobs to do.
|
if (!$hasJobsToDo) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// The $lastDurationWasTooShort check prevents scheduling the next immediate action in case the last run was suspiciously short.
|
// The $lastDurationWasTooShort check prevents scheduling the next immediate action in case the last run was suspiciously short.
|
||||||
// If there was still some execution time left, the daemon should have been continued.
|
// If there was still some execution time left, the daemon should have been continued.
|
||||||
if ($this->wordpressTrigger->checkExecutionRequirements() && !$lastDurationWasTooShort) {
|
$lastDurationWasTooShort = ($this->lastRunDuration < self::SHORT_DURATION_THRESHOLD) && ($this->remainingExecutionLimit > 0);
|
||||||
$this->actionScheduler->scheduleImmediateSingleAction(self::NAME);
|
if ($lastDurationWasTooShort) {
|
||||||
// The automatic rescheduling schedules the next recurring action to run after 1 second.
|
return;
|
||||||
// So we need to wait before we trigger new remote executor to avoid skipping the action
|
|
||||||
sleep(2);
|
|
||||||
$this->remoteExecutorHandler->triggerExecutor();
|
|
||||||
}
|
}
|
||||||
|
$this->actionScheduler->scheduleImmediateSingleAction(self::NAME);
|
||||||
|
// The automatic rescheduling schedules the next recurring action to run after 1 second.
|
||||||
|
// So we need to wait before we trigger new remote executor to avoid skipping the action
|
||||||
|
sleep(2);
|
||||||
|
$this->remoteExecutorHandler->triggerExecutor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user