Don't use pydantic to type-verify outgoing messages

This commit is contained in:
Matthias
2022-10-25 19:36:40 +02:00
parent 32600a113f
commit 3fa50077c9
4 changed files with 20 additions and 13 deletions

View File

@@ -16,7 +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.api_server.ws_schemas import WSMessageSchemaType
from freqtrade.rpc.rpc import RPC, RPCException, RPCHandler
@@ -131,7 +131,7 @@ class ApiServer(RPCHandler):
def send_msg(self, msg: Dict[str, Any]) -> None:
if self._ws_queue:
sync_q = self._ws_queue.sync_q
sync_q.put(WSMessageSchema(**msg))
sync_q.put(msg)
def handle_rpc_exception(self, request, exc):
logger.exception(f"API Error calling: {exc}")
@@ -195,8 +195,8 @@ class ApiServer(RPCHandler):
while True:
logger.debug("Getting queue messages...")
# Get data from queue
message: WSMessageSchema = await async_queue.get()
logger.debug(f"Found message of type: {message.type}")
message: WSMessageSchemaType = await async_queue.get()
logger.debug(f"Found message of type: {message.get('type')}")
# Broadcast it
await self._ws_channel_manager.broadcast(message)
except asyncio.CancelledError: