Update job database while locking the threads

This commit is contained in:
Théophile Diot 2022-12-14 18:05:31 +01:00
parent ea4ceae7b3
commit 13fbbfb67e
No known key found for this signature in database
GPG Key ID: E752C80DB72BB014
1 changed files with 8 additions and 7 deletions

View File

@ -114,21 +114,22 @@ class JobScheduler(ApiCaller):
)
except BaseException:
success = False
self.__logger.error(
f"Exception while executing job {name} from plugin {plugin} :\n{format_exc()}",
)
with self.__thread_lock:
self.__logger.error(
f"Exception while executing job {name} from plugin {plugin} :\n{format_exc()}",
)
self.__job_success = False
if self.__job_success and proc.returncode >= 2:
success = False
self.__logger.error(
f"Error while executing job {name} from plugin {plugin}",
)
with self.__thread_lock:
self.__logger.error(
f"Error while executing job {name} from plugin {plugin}",
)
self.__job_success = False
err = self.__db.update_job(plugin, name, success)
with self.__thread_lock:
err = self.__db.update_job(plugin, name, success)
if not err:
self.__logger.info(