From 10090a36d59dd4997f43a52424209564a70507e9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 23 Oct 2022 14:51:17 +0200 Subject: [PATCH] simplify throttle --- freqtrade/worker.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/freqtrade/worker.py b/freqtrade/worker.py index 9b81764b6..a8bb931f8 100755 --- a/freqtrade/worker.py +++ b/freqtrade/worker.py @@ -35,7 +35,6 @@ class Worker: self._config = config self._init(False) - self.last_throttle_start_time: float = 0 self._heartbeat_msg: float = 0 # Tell systemd that we completed initialization phase @@ -135,10 +134,10 @@ class Worker: :param throttle_secs: throttling interation execution time limit in seconds :return: Any (result of execution of func) """ - self.last_throttle_start_time = time.time() + last_throttle_start_time = time.time() logger.debug("========================================") result = func(*args, **kwargs) - time_passed = time.time() - self.last_throttle_start_time + time_passed = time.time() - last_throttle_start_time 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.")