Skip to content

Commit

Permalink
Fix potential race conditions between RPC and Freqtradebot during ini…
Browse files Browse the repository at this point in the history
…tialization
  • Loading branch information
hroff-1902 committed Oct 24, 2019
1 parent 470efd6 commit 2e1e080
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions freqtrade/freqtradebot.py
Expand Up @@ -55,8 +55,6 @@ def __init__(self, config: Dict[str, Any]) -> None:
# 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)
Expand All @@ -83,6 +81,13 @@ def __init__(self, config: Dict[str, Any]) -> None:
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
Expand Down

0 comments on commit 2e1e080

Please sign in to comment.