From 32600a113f7aed46e241a6de905ceb7be2f45f25 Mon Sep 17 00:00:00 2001 From: Timothy Pogue Date: Mon, 24 Oct 2022 12:21:17 -0600 Subject: [PATCH] fix broadcast --- freqtrade/rpc/api_server/webserver.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/freqtrade/rpc/api_server/webserver.py b/freqtrade/rpc/api_server/webserver.py index c6639f1a6..22a05f07b 100644 --- a/freqtrade/rpc/api_server/webserver.py +++ b/freqtrade/rpc/api_server/webserver.py @@ -16,6 +16,7 @@ from freqtrade.constants import Config from freqtrade.exceptions import OperationalException from freqtrade.rpc.api_server.uvicorn_threaded import UvicornServer from freqtrade.rpc.api_server.ws import ChannelManager +from freqtrade.rpc.api_server.ws_schemas import WSMessageSchema from freqtrade.rpc.rpc import RPC, RPCException, RPCHandler @@ -127,10 +128,10 @@ class ApiServer(RPCHandler): cls._has_rpc = False cls._rpc = None - def send_msg(self, msg: Dict[str, str]) -> None: + def send_msg(self, msg: Dict[str, Any]) -> None: if self._ws_queue: sync_q = self._ws_queue.sync_q - sync_q.put(msg) + sync_q.put(WSMessageSchema(**msg)) def handle_rpc_exception(self, request, exc): logger.exception(f"API Error calling: {exc}") @@ -194,8 +195,8 @@ class ApiServer(RPCHandler): while True: logger.debug("Getting queue messages...") # Get data from queue - message = await async_queue.get() - logger.debug(f"Found message of type: {message.get('type')}") + message: WSMessageSchema = await async_queue.get() + logger.debug(f"Found message of type: {message.type}") # Broadcast it await self._ws_channel_manager.broadcast(message) except asyncio.CancelledError: