minor improvements, fixes, old config+constant removal

This commit is contained in:
Timothy Pogue
2022-09-04 10:22:10 -06:00
parent 1601868854
commit 07f806a314
10 changed files with 51 additions and 38 deletions

View File

@@ -50,6 +50,7 @@ def get_user_from_token(token, secret_key: str, token_type: str = "access"):
# This should be reimplemented to better realign with the existing tools provided
# by FastAPI regarding API Tokens
# https://github.com/tiangolo/fastapi/blob/master/fastapi/security/api_key.py
async def get_ws_token(
ws: WebSocket,
token: Union[str, None] = None,

View File

@@ -2,23 +2,30 @@ import logging
from typing import Any, Dict
from fastapi import APIRouter, Depends, WebSocket, WebSocketDisconnect
# fastapi does not make this available through it, so import directly from starlette
from starlette.websockets import WebSocketState
from freqtrade.enums import RPCMessageType, RPCRequestType
from freqtrade.rpc.api_server.deps import get_channel_manager, get_rpc
from freqtrade.rpc.api_server.ws.channel import WebSocketChannel
from freqtrade.rpc.api_server.ws.utils import is_websocket_alive
from freqtrade.rpc.rpc import RPC
# from typing import Any, Dict
logger = logging.getLogger(__name__)
# Private router, protected by API Key authentication
router = APIRouter()
async def is_websocket_alive(ws: WebSocket) -> bool:
if (
ws.application_state == WebSocketState.CONNECTED and
ws.client_state == WebSocketState.CONNECTED
):
return True
return False
async def _process_consumer_request(
request: Dict[str, Any],
channel: WebSocketChannel,

View File

@@ -205,7 +205,7 @@ class ApiServer(RPCHandler):
# For testing, shouldn't happen when stable
except Exception as e:
logger.info(f"Exception happened in background task: {e}")
logger.exception(f"Exception happened in background task: {e}")
def start_api(self):
"""
@@ -244,8 +244,7 @@ class ApiServer(RPCHandler):
if self._standalone:
self._server.run()
else:
if self._config.get('api_server', {}).get('enable_message_ws', False):
self.start_message_queue()
self.start_message_queue()
self._server.run_in_thread()
except Exception:
logger.exception("Api server failed to start.")

View File

@@ -289,7 +289,7 @@ class ExternalMessageConsumer:
return
# Add the pairlist data to the DataProvider
self._dp.set_producer_pairs(message_data, producer_name=producer_name)
self._dp._set_producer_pairs(message_data, producer_name=producer_name)
logger.debug(f"Consumed message from {producer_name} of type RPCMessageType.WHITELIST")
@@ -309,8 +309,8 @@ class ExternalMessageConsumer:
dataframe = remove_entry_exit_signals(dataframe)
# Add the dataframe to the dataprovider
self._dp.add_external_df(pair, timeframe, dataframe,
candle_type, producer_name=producer_name)
self._dp._add_external_df(pair, dataframe, timeframe,
candle_type, producer_name=producer_name)
logger.debug(
f"Consumed message from {producer_name} of type RPCMessageType.ANALYZED_DF")