Fix potential race conditions between RPC and Freqtradebot during initialization

This commit is contained in:
hroff-1902 2019-10-24 22:33:44 +03:00
parent 470efd6f40
commit 2e1e080022

View File

@ -55,8 +55,6 @@ class FreqtradeBot:
# Check config consistency here since strategies can set certain options # Check config consistency here since strategies can set certain options
validate_config_consistency(config) validate_config_consistency(config)
self.rpc: RPCManager = RPCManager(self)
self.exchange = ExchangeResolver(self.config['exchange']['name'], self.config).exchange self.exchange = ExchangeResolver(self.config['exchange']['name'], self.config).exchange
self.wallets = Wallets(self.config, self.exchange) self.wallets = Wallets(self.config, self.exchange)
@ -83,6 +81,13 @@ class FreqtradeBot:
initial_state = self.config.get('initial_state') initial_state = self.config.get('initial_state')
self.state = State[initial_state.upper()] if initial_state else State.STOPPED self.state = State[initial_state.upper()] if initial_state else State.STOPPED
# RPC runs in separate threads, can start handling external commands just after
# initialization, even before Freqtradebot has a chance to start its throttling,
# so anything in the Freqtradebot instance should be ready (initialized), including
# the initial state of the bot.
# Keep this at the end of this initialization method.
self.rpc: RPCManager = RPCManager(self)
def cleanup(self) -> None: def cleanup(self) -> None:
""" """
Cleanup pending resources on an already stopped bot Cleanup pending resources on an already stopped bot