Merge pull request #2415 from hroff-1902/rpc-race

minor: Fix potential race conditions between RPC and Freqtradebot
This commit is contained in:
Matthias 2019-10-25 06:14:59 +02:00 committed by GitHub
commit 514e073c57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,8 +55,6 @@ class FreqtradeBot:
# Check config consistency here since strategies can set certain options
validate_config_consistency(config)
self.rpc: RPCManager = RPCManager(self)
self.exchange = ExchangeResolver(self.config['exchange']['name'], self.config).exchange
self.wallets = Wallets(self.config, self.exchange)
@ -83,6 +81,13 @@ class FreqtradeBot:
initial_state = self.config.get('initial_state')
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:
"""
Cleanup pending resources on an already stopped bot