Run webserver in main thread when using webserver mode
This commit is contained in:
parent
37b15e830a
commit
03140a0ecb
@ -339,14 +339,14 @@ def api_get_backtest():
|
|||||||
Get backtesting result.
|
Get backtesting result.
|
||||||
Returns Result after backtesting has been ran.
|
Returns Result after backtesting has been ran.
|
||||||
"""
|
"""
|
||||||
from freqtrade.persistence import Trade
|
from freqtrade.persistence import LocalTrade
|
||||||
if ApiServer._bgtask_running:
|
if ApiServer._bgtask_running:
|
||||||
return {
|
return {
|
||||||
"status": "running",
|
"status": "running",
|
||||||
"running": True,
|
"running": True,
|
||||||
"step": ApiServer._bt.get_action() if ApiServer._bt else str(BacktestState.STARTUP),
|
"step": ApiServer._bt.get_action() if ApiServer._bt else str(BacktestState.STARTUP),
|
||||||
"progress": ApiServer._bt.get_progress() if ApiServer._bt else 0,
|
"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",
|
"status_msg": "Backtest running",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +166,9 @@ class ApiServer(RPCHandler):
|
|||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
self._server = UvicornServer(uvconfig)
|
self._server = UvicornServer(uvconfig)
|
||||||
self._server.run_in_thread()
|
if self._standalone:
|
||||||
|
self._server.run()
|
||||||
|
else:
|
||||||
|
self._server.run_in_thread()
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("Api server failed to start.")
|
logger.exception("Api server failed to start.")
|
||||||
|
Loading…
Reference in New Issue
Block a user