catch RuntimeError earlier

This makes it possible to to restart the bot, if there are temporary
server issues.
This commit is contained in:
gcarq 2017-11-06 01:03:37 +01:00
parent cc29126d61
commit a37ea13fd1

View File

@ -60,6 +60,13 @@ def _process() -> None:
msg = 'Got {} in _process(), retrying in 30 seconds...'.format(error.__class__.__name__)
logger.exception(msg)
time.sleep(30)
except RuntimeError:
telegram.send_msg('*Status:* Got RuntimeError:\n```\n{traceback}```{hint}'.format(
traceback=traceback.format_exc(),
hint='Issue `/start` if you think it is save to restart.'
))
logger.exception('Got RuntimeError. Stopping trader ...')
update_state(State.STOPPED)
def close_trade_if_fulfilled(trade: Trade) -> bool:
@ -254,7 +261,7 @@ def app(config: dict) -> None:
"""
logger.info('Starting freqtrade %s', __version__)
init(config)
try:
old_state = get_state()
logger.info('Initial State: %s', old_state)
telegram.send_msg('*Status:* `{}`'.format(old_state.name.lower()))
@ -272,11 +279,6 @@ def app(config: dict) -> None:
# We need to sleep here because otherwise we would run into bittrex rate limit
time.sleep(exchange.get_sleep_time())
old_state = new_state
except RuntimeError:
telegram.send_msg(
'*Status:* Got RuntimeError:\n```\n{}\n```'.format(traceback.format_exc())
)
logger.exception('RuntimeError. Trader stopped!')
def main():