mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Better throttling
This commit is contained in:
parent
78ee36a8c6
commit
04aa74e5ad
|
@ -108,12 +108,13 @@ class Worker:
|
||||||
:return: Any
|
:return: Any
|
||||||
"""
|
"""
|
||||||
start = time.time()
|
start = time.time()
|
||||||
result = func(*args, **kwargs)
|
|
||||||
logger.debug("========================================")
|
logger.debug("========================================")
|
||||||
end = time.time()
|
result = func(*args, **kwargs)
|
||||||
duration = max(min_secs - (end - start), 0.0)
|
time_passed = time.time() - start
|
||||||
logger.debug(f"Throttling {func.__name__} for {duration:.2f} seconds")
|
sleep_duration = max(min_secs - time_passed, 0.0)
|
||||||
time.sleep(duration)
|
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)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _process_stopped(self) -> None:
|
def _process_stopped(self) -> None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user