mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
parent
b328a18a97
commit
abc3badfb5
|
@ -155,6 +155,8 @@ class FreqtradeBot(LoggingMixin):
|
|||
self.cancel_all_open_orders()
|
||||
|
||||
self.check_for_open_trades()
|
||||
except Exception as e:
|
||||
logger.warning(f'Exception during cleanup: {e.__class__.__name__} {e}')
|
||||
|
||||
finally:
|
||||
self.strategy.ft_bot_cleanup()
|
||||
|
@ -162,8 +164,13 @@ class FreqtradeBot(LoggingMixin):
|
|||
self.rpc.cleanup()
|
||||
if self.emc:
|
||||
self.emc.shutdown()
|
||||
Trade.commit()
|
||||
self.exchange.close()
|
||||
try:
|
||||
Trade.commit()
|
||||
except Exception:
|
||||
# Exeptions here will be happening if the db disappeared.
|
||||
# At which point we can no longer commit anyway.
|
||||
pass
|
||||
|
||||
def startup(self) -> None:
|
||||
"""
|
||||
|
|
|
@ -88,6 +88,18 @@ def test_bot_cleanup(mocker, default_conf_usdt, caplog) -> None:
|
|||
assert coo_mock.call_count == 1
|
||||
|
||||
|
||||
def test_bot_cleanup_db_errors(mocker, default_conf_usdt, caplog) -> None:
|
||||
mocker.patch('freqtrade.freqtradebot.Trade.commit',
|
||||
side_effect=OperationalException())
|
||||
mocker.patch('freqtrade.freqtradebot.FreqtradeBot.check_for_open_trades',
|
||||
side_effect=OperationalException())
|
||||
freqtrade = get_patched_freqtradebot(mocker, default_conf_usdt)
|
||||
freqtrade.emc = MagicMock()
|
||||
freqtrade.emc.shutdown = MagicMock()
|
||||
freqtrade.cleanup()
|
||||
assert freqtrade.emc.shutdown.call_count == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize('runmode', [
|
||||
RunMode.DRY_RUN,
|
||||
RunMode.LIVE
|
||||
|
|
Loading…
Reference in New Issue
Block a user