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
|
||||
"""
|
||||
start = time.time()
|
||||
result = func(*args, **kwargs)
|
||||
logger.debug("========================================")
|
||||
end = time.time()
|
||||
duration = max(min_secs - (end - start), 0.0)
|
||||
logger.debug(f"Throttling {func.__name__} for {duration:.2f} seconds")
|
||||
time.sleep(duration)
|
||||
result = func(*args, **kwargs)
|
||||
time_passed = time.time() - start
|
||||
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.")
|
||||
time.sleep(sleep_duration)
|
||||
return result
|
||||
|
||||
def _process_stopped(self) -> None:
|
||||
|
|
Loading…
Reference in New Issue
Block a user