Rollback after each request

This closes the transaction and avoids "sticking" transactions.
This commit is contained in:
Matthias
2021-10-17 08:36:11 +02:00
parent 89ca8abea9
commit fb2c8f7621
3 changed files with 5 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, Optional
from typing import Any, Dict, Iterator, Optional
from freqtrade.persistence import Trade
from freqtrade.rpc.rpc import RPC, RPCException
@@ -12,11 +12,12 @@ def get_rpc_optional() -> Optional[RPC]:
return None
def get_rpc() -> Optional[RPC]:
def get_rpc() -> Optional[Iterator[RPC]]:
_rpc = get_rpc_optional()
if _rpc:
Trade.query.session.rollback()
return _rpc
yield _rpc
Trade.query.session.rollback()
else:
raise RPCException('Bot is not in the correct state')