From 775b04006ac8605220d6803d15bcfac30f91c174 Mon Sep 17 00:00:00 2001 From: tazlin Date: Mon, 4 Mar 2024 12:52:19 -0500 Subject: [PATCH] fix: accurate mps pause logic The previous stand in of waiting a fixed number of seconds can be replaced by waiting an amount appropriate for the queue --- .../process_management/process_manager.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/horde_worker_regen/process_management/process_manager.py b/horde_worker_regen/process_management/process_manager.py index 051332da..9658238f 100644 --- a/horde_worker_regen/process_management/process_manager.py +++ b/horde_worker_regen/process_management/process_manager.py @@ -2372,14 +2372,14 @@ async def api_job_pop(self) -> None: if self.should_wait_for_pending_megapixelsteps(): # Assuming a megapixelstep takes 0.75 seconds, if 2/3 of the time has passed since the limit was triggered, # we can assume that the pending megapixelsteps will be below the limit soon. Otherwise we continue to wait - seconds_to_wait = (self._max_pending_megapixelsteps * 0.75) * (2 / 3) + seconds_to_wait = (self.get_pending_megapixelsteps() * 0.75) * (2 / 3) if self.bridge_data.high_performance_mode: seconds_to_wait *= 0.35 - logger.debug("High performance mode is enabled, reducing the wait time by 70%") + # logger.debug("High performance mode is enabled, reducing the wait time by 70%") elif self.bridge_data.moderate_performance_mode: seconds_to_wait *= 0.5 - logger.debug("Moderate performance mode is enabled, reducing the wait time by 50%") + # logger.debug("Moderate performance mode is enabled, reducing the wait time by 50%") # if self.get_pending_megapixelsteps() > 200: # seconds_to_wait = self._max_pending_megapixelsteps * 0.75 @@ -2393,9 +2393,13 @@ async def api_job_pop(self) -> None: ) logger.debug( f"Pending megapixelsteps: {self.get_pending_megapixelsteps()} | " - f"Max pending megapixelsteps: {self._max_pending_megapixelsteps} | ", + f"Max pending megapixelsteps: {self._max_pending_megapixelsteps} | " f"Scheduled to wait for {seconds_to_wait} seconds", ) + logger.debug( + f"high_performance_mode: {self.bridge_data.high_performance_mode} | " + f"moderate_performance_mode: {self.bridge_data.moderate_performance_mode}", + ) return if not (time.time() - self._triggered_max_pending_megapixelsteps_time) > seconds_to_wait: