Use combined exception handler at startup

This commit is contained in:
Matthias 2024-03-19 07:02:48 +01:00
parent b5548dbee0
commit ebd516cadb
2 changed files with 4 additions and 8 deletions

View File

@ -23,11 +23,6 @@ def start_trading(args: Dict[str, Any]) -> int:
signal.signal(signal.SIGTERM, term_handler)
worker = Worker(args)
worker.run()
except Exception as e:
logger.error(str(e))
logger.exception("Fatal exception!")
except (KeyboardInterrupt):
logger.info('SIGINT received, aborting ...')
finally:
if worker:
logger.info("worker found ... calling exit")

View File

@ -51,15 +51,16 @@ def test_start_trading_fail(mocker, caplog):
'trade',
'-c', 'tests/testdata/testconfigs/main_test_config.json'
]
with pytest.raises(OperationalException):
start_trading(get_args(args))
assert exitmock.call_count == 1
exitmock.reset_mock()
caplog.clear()
mocker.patch("freqtrade.worker.Worker.__init__", MagicMock(side_effect=OperationalException))
with pytest.raises(OperationalException):
start_trading(get_args(args))
assert exitmock.call_count == 0
assert log_has('Fatal exception!', caplog)
def test_start_webserver(mocker, caplog):