chore: Handle read-only mode in JobScheduler methods

This commit is contained in:
Théophile Diot 2024-05-28 16:41:24 +01:00
parent 3752e0d989
commit d85b0ff69c
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06

View file

@ -238,6 +238,7 @@ class JobScheduler(ApiCaller):
err = self.try_database_readonly()
if err:
self.__logger.error("Database is in read-only mode, pending jobs will not be executed")
return True
self.__job_success = True
@ -278,6 +279,7 @@ class JobScheduler(ApiCaller):
def run_once(self, plugins: Optional[List[str]] = None) -> bool:
err = self.try_database_readonly()
if err:
self.__logger.error("Database is in read-only mode, jobs will not be executed")
return True
threads = []
@ -310,6 +312,7 @@ class JobScheduler(ApiCaller):
def run_single(self, job_name: str) -> bool:
err = self.try_database_readonly()
if err:
self.__logger.error(f"Database is in read-only mode, single job {job_name} will not be executed")
return True
if self.__lock:
@ -384,7 +387,4 @@ class JobScheduler(ApiCaller):
self.db.retry_connection(fallback=True, log=False)
self.db.readonly = True
if self.db.readonly:
self.__logger.error("Database is in read-only mode, jobs will not be executed")
return self.db.readonly