From d79faf9e295a937578ce8ec2a8454f759715e67c Mon Sep 17 00:00:00 2001 From: tazlin <tazlin.on.github@gmail.com> Date: Mon, 4 Mar 2024 07:21:15 -0500 Subject: [PATCH] fix: avoid exceptions on lock releases --- .../process_management/process_manager.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/horde_worker_regen/process_management/process_manager.py b/horde_worker_regen/process_management/process_manager.py index 99267581..051332da 100644 --- a/horde_worker_regen/process_management/process_manager.py +++ b/horde_worker_regen/process_management/process_manager.py @@ -1120,9 +1120,16 @@ def _replace_inference_process(self, process_info: HordeProcessInfo) -> None: logger.warning(f"Job {job.id_} not found in job_pop_timestamps") if process_info.last_process_state == HordeProcessState.INFERENCE_STARTING: - self._inference_semaphore.release() + try: + self._inference_semaphore.release() + except ValueError: + logger.debug("Inference semaphore already released") elif process_info.last_process_state == HordeProcessState.DOWNLOADING_AUX_MODEL: - self._aux_model_lock.release() + try: + self._aux_model_lock.release() + except ValueError: + logger.debug("Aux model lock already released") + self._start_inference_process(process_info.process_id) total_num_completed_jobs: int = 0