taskProcessingManager->getProviders(); foreach ($providers as $provider) { if (!$provider instanceof ISynchronousProvider) { continue; } $taskType = $provider->getTaskTypeId(); try { $task = $this->taskProcessingManager->getNextScheduledTask($taskType); } catch (NotFoundException $e) { continue; } catch (Exception $e) { $this->logger->error('Unknown error while retrieving scheduled TaskProcessing tasks', ['exception' => $e]); continue; } try { try { $input = $this->taskProcessingManager->prepareInputData($task); } catch (GenericFileException|NotPermittedException|LockedException|ValidationException $e) { $this->logger->warning('Failed to prepare input data for a TaskProcessing task with synchronous provider ' . $provider->getId(), ['exception' => $e]); $this->taskProcessingManager->setTaskResult($task->getId(), $e->getMessage(), null); // Schedule again $this->jobList->add(self::class, $argument); return; } try { $output = $provider->process($task->getUserId(), $input); } catch (ProcessingException $e) { $this->logger->warning('Failed to process a TaskProcessing task with synchronous provider ' . $provider->getId(), ['exception' => $e]); $this->taskProcessingManager->setTaskResult($task->getId(), $e->getMessage(), null); // Schedule again $this->jobList->add(self::class, $argument); return; } catch (\Throwable $e) { $this->logger->error('Unknown error while processing TaskProcessing task', ['exception' => $e]); $this->taskProcessingManager->setTaskResult($task->getId(), $e->getMessage(), null); // Schedule again $this->jobList->add(self::class, $argument); return; } $this->taskProcessingManager->setTaskResult($task->getId(), null, $output); } catch (NotFoundException $e) { $this->logger->info('Could not find task anymore after execution. Moving on.', ['exception' => $e]); } catch (Exception $e) { $this->logger->error('Failed to report result of TaskProcessing task', ['exception' => $e]); } } // Schedule again $this->jobList->add(self::class, $argument); } }