Improve test for worker throttle

This commit is contained in:
Matthias
2022-10-23 14:17:01 +02:00
parent c36141594e
commit d0571464db
2 changed files with 45 additions and 2 deletions

View File

@@ -142,9 +142,14 @@ class Worker:
sleep_duration = max(throttle_secs - time_passed, 0.0)
logger.debug(f"Throttling with '{func.__name__}()': sleep for {sleep_duration:.2f} s, "
f"last iteration took {time_passed:.2f} s.")
time.sleep(sleep_duration)
self._sleep(sleep_duration)
return result
@staticmethod
def _sleep(sleep_duration: float) -> None:
"""Local sleep method - to improve testability"""
time.sleep(sleep_duration)
def _process_stopped(self) -> None:
self.freqtrade.process_stopped()