From 575d3fa5b4ea9469fa46744a577d4c450e84441a Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Sun, 15 Oct 2023 11:37:51 +0200 Subject: [PATCH] fix(ClassifierJob): Fix concurrency limit being overzealous see #967 Signed-off-by: Marcel Klehr --- lib/BackgroundJobs/ClassifierJob.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/BackgroundJobs/ClassifierJob.php b/lib/BackgroundJobs/ClassifierJob.php index 0bdac164..685344a4 100644 --- a/lib/BackgroundJobs/ClassifierJob.php +++ b/lib/BackgroundJobs/ClassifierJob.php @@ -17,14 +17,14 @@ use Psr\Log\LoggerInterface; abstract class ClassifierJob extends TimedJob { - + public function __construct( ITimeFactory $time, private LoggerInterface $logger, private QueueService $queue, private IUserMountCache $userMountCache, private IJobList $jobList, - private SettingsService $settingsService + private SettingsService $settingsService, ) { parent::__construct($time); $this->setInterval(60 * 5); @@ -34,7 +34,7 @@ public function __construct( protected function runClassifier(string $model, array $argument): void { sleep(10); - if ($this->settingsService->getSetting('concurrency.enabled') !== 'true' && $this->anyClassifierJobsRunning()) { + if ($this->settingsService->getSetting('concurrency.enabled') !== 'true' && $this->anyOtherClassifierJobsRunning()) { $this->logger->debug('Stalling job '.static::class.' with argument ' . var_export($argument, true) . ' because other classifiers are already reserved'); return; } @@ -114,7 +114,7 @@ abstract protected function classify(array $files) : void; /** * @return bool */ - private function anyClassifierJobsRunning() { + private function anyOtherClassifierJobsRunning() { foreach ([ ClassifyFacesJob::class, ClassifyImagenetJob::class, @@ -122,8 +122,12 @@ private function anyClassifierJobsRunning() { ClassifyMovinetJob::class, ClassifyMusicnnJob::class, ] as $jobClass) { - if ($this->jobList->hasReservedJob($jobClass)) { - return true; + if ($jobClass === self::class) { + continue; + } else { + if ($this->jobList->hasReservedJob($jobClass)) { + return true; + } } } return false;