mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 02:12:01 +00:00
Use combined exception handler at startup
This commit is contained in:
parent
b5548dbee0
commit
ebd516cadb
|
@ -23,11 +23,6 @@ def start_trading(args: Dict[str, Any]) -> int:
|
||||||
signal.signal(signal.SIGTERM, term_handler)
|
signal.signal(signal.SIGTERM, term_handler)
|
||||||
worker = Worker(args)
|
worker = Worker(args)
|
||||||
worker.run()
|
worker.run()
|
||||||
except Exception as e:
|
|
||||||
logger.error(str(e))
|
|
||||||
logger.exception("Fatal exception!")
|
|
||||||
except (KeyboardInterrupt):
|
|
||||||
logger.info('SIGINT received, aborting ...')
|
|
||||||
finally:
|
finally:
|
||||||
if worker:
|
if worker:
|
||||||
logger.info("worker found ... calling exit")
|
logger.info("worker found ... calling exit")
|
||||||
|
|
|
@ -51,15 +51,16 @@ def test_start_trading_fail(mocker, caplog):
|
||||||
'trade',
|
'trade',
|
||||||
'-c', 'tests/testdata/testconfigs/main_test_config.json'
|
'-c', 'tests/testdata/testconfigs/main_test_config.json'
|
||||||
]
|
]
|
||||||
start_trading(get_args(args))
|
with pytest.raises(OperationalException):
|
||||||
|
start_trading(get_args(args))
|
||||||
assert exitmock.call_count == 1
|
assert exitmock.call_count == 1
|
||||||
|
|
||||||
exitmock.reset_mock()
|
exitmock.reset_mock()
|
||||||
caplog.clear()
|
caplog.clear()
|
||||||
mocker.patch("freqtrade.worker.Worker.__init__", MagicMock(side_effect=OperationalException))
|
mocker.patch("freqtrade.worker.Worker.__init__", MagicMock(side_effect=OperationalException))
|
||||||
start_trading(get_args(args))
|
with pytest.raises(OperationalException):
|
||||||
|
start_trading(get_args(args))
|
||||||
assert exitmock.call_count == 0
|
assert exitmock.call_count == 0
|
||||||
assert log_has('Fatal exception!', caplog)
|
|
||||||
|
|
||||||
|
|
||||||
def test_start_webserver(mocker, caplog):
|
def test_start_webserver(mocker, caplog):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user