Use scheduler as Object, not the automatic Singleton

This commit is contained in:
Matthias 2021-10-11 20:28:23 +02:00
parent bdad604fab
commit 70000b5843
2 changed files with 5 additions and 4 deletions

View File

@ -10,7 +10,7 @@ from threading import Lock
from typing import Any, Dict, List, Optional
import arrow
import schedule
from schedule import Scheduler
from freqtrade import __version__, constants
from freqtrade.configuration import validate_config_consistency
@ -109,6 +109,7 @@ class FreqtradeBot(LoggingMixin):
self.trading_mode = TradingMode(self.config['trading_mode'])
else:
self.trading_mode = TradingMode.SPOT
self._schedule = Scheduler()
if self.trading_mode == TradingMode.FUTURES:
@ -121,7 +122,7 @@ class FreqtradeBot(LoggingMixin):
for time_slot in range(0, 24):
for minutes in [0, 15, 30, 45]:
t = str(time(time_slot, minutes, 2))
schedule.every().day.at(t).do(update)
self._schedule.every().day.at(t).do(update)
def notify_status(self, msg: str) -> None:
"""
@ -293,7 +294,7 @@ class FreqtradeBot(LoggingMixin):
logger.warning(f"Error updating Order {order.order_id} due to {e}")
if self.trading_mode == TradingMode.FUTURES:
schedule.run_pending()
self._schedule.run_pending()
def update_closed_trades_without_assigned_fees(self):
"""

View File

@ -4303,6 +4303,6 @@ def test_update_funding_fees(mocker, default_conf, trading_mode, calls, time_mac
freqtrade = get_patched_freqtradebot(mocker, default_conf)
time_machine.move_to(f"{t2} +00:00")
schedule.run_pending()
freqtrade._schedule.run_pending()
assert freqtrade.update_funding_fees.call_count == calls