From e0800b7c29fb0fe3b53afe2fa6732da7f37e06c1 Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Fri, 21 Feb 2020 03:52:14 +0300 Subject: [PATCH] Make throttle start time an worker object attribute --- freqtrade/worker.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/freqtrade/worker.py b/freqtrade/worker.py index 40bfb54d8..dc8f9109f 100755 --- a/freqtrade/worker.py +++ b/freqtrade/worker.py @@ -32,6 +32,8 @@ class Worker: self._config = config self._init(False) + self.last_throttle_start_time: float = None + # Tell systemd that we completed initialization phase if self._sd_notify: logger.debug("sd_notify: READY=1") @@ -107,10 +109,10 @@ class Worker: :param min_secs: minimum execution time in seconds :return: Any """ - start = time.time() + self.last_throttle_start_time = time.time() logger.debug("========================================") result = func(*args, **kwargs) - time_passed = time.time() - start + time_passed = time.time() - self.last_throttle_start_time sleep_duration = max(min_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.")