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) 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")

View File

@ -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):