From 03140a0ecbee240446bae65791a12f69feb2092a Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 21 Mar 2021 10:45:44 +0100 Subject: [PATCH] Run webserver in main thread when using webserver mode --- freqtrade/rpc/api_server/api_v1.py | 4 ++-- freqtrade/rpc/api_server/webserver.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/freqtrade/rpc/api_server/api_v1.py b/freqtrade/rpc/api_server/api_v1.py index 339f8565a..fd3cb345e 100644 --- a/freqtrade/rpc/api_server/api_v1.py +++ b/freqtrade/rpc/api_server/api_v1.py @@ -339,14 +339,14 @@ def api_get_backtest(): Get backtesting result. Returns Result after backtesting has been ran. """ - from freqtrade.persistence import Trade + from freqtrade.persistence import LocalTrade if ApiServer._bgtask_running: return { "status": "running", "running": True, "step": ApiServer._bt.get_action() if ApiServer._bt else str(BacktestState.STARTUP), "progress": ApiServer._bt.get_progress() if ApiServer._bt else 0, - "trade_count": Trade.get_trades_proxy(is_open=False), + "trade_count": len(LocalTrade.trades), "status_msg": "Backtest running", } diff --git a/freqtrade/rpc/api_server/webserver.py b/freqtrade/rpc/api_server/webserver.py index eccbadcb3..ac394b59d 100644 --- a/freqtrade/rpc/api_server/webserver.py +++ b/freqtrade/rpc/api_server/webserver.py @@ -166,6 +166,9 @@ class ApiServer(RPCHandler): ) try: self._server = UvicornServer(uvconfig) - self._server.run_in_thread() + if self._standalone: + self._server.run() + else: + self._server.run_in_thread() except Exception: logger.exception("Api server failed to start.")