Allow immediate processing of just prepared tasks in cron worker runner

Preparing simple worker tasks is super fast, because it just switches the state to null.
But the processing of just prepared tasks required the second worker run and also second cron run.
This change optimize the behavior and in case there is still time left it immediately starts processing the tasks.
[MAILPOET-4684]
This commit is contained in:
Rostislav Wolny
2022-09-29 14:36:07 +02:00
committed by Aschepikov
parent 05b441378d
commit 69ac29d0a7
3 changed files with 9 additions and 17 deletions

View File

@@ -73,6 +73,8 @@ class CronWorkerRunner {
foreach ($dueTasks as $task) {
$this->prepareTask($worker, $task);
}
// Re-fetch running tasks so that we can process tasks that were just prepared
$runningTasks = $this->getRunningTasks($worker);
foreach ($runningTasks as $task) {
$this->processTask($worker, $task);
}