From eb8c89fe3188fefc284d0c825ab29e98c59096ab Mon Sep 17 00:00:00 2001 From: Timothy Pogue Date: Mon, 10 Oct 2022 23:32:10 -0600 Subject: [PATCH] move send delay to relay --- freqtrade/rpc/api_server/webserver.py | 4 ---- freqtrade/rpc/api_server/ws/channel.py | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/freqtrade/rpc/api_server/webserver.py b/freqtrade/rpc/api_server/webserver.py index 4a09fd78e..c6639f1a6 100644 --- a/freqtrade/rpc/api_server/webserver.py +++ b/freqtrade/rpc/api_server/webserver.py @@ -198,10 +198,6 @@ class ApiServer(RPCHandler): logger.debug(f"Found message of type: {message.get('type')}") # Broadcast it await self._ws_channel_manager.broadcast(message) - # Limit messages per sec. - # Could cause problems with queue size if too low, and - # problems with network traffik if too high. - await asyncio.sleep(0.001) except asyncio.CancelledError: pass diff --git a/freqtrade/rpc/api_server/ws/channel.py b/freqtrade/rpc/api_server/ws/channel.py index 7cee95e6d..e9dbd63be 100644 --- a/freqtrade/rpc/api_server/ws/channel.py +++ b/freqtrade/rpc/api_server/ws/channel.py @@ -115,6 +115,12 @@ class WebSocketChannel: try: await self._send(message) self.queue.task_done() + + # Limit messages per sec. + # Could cause problems with queue size if too low, and + # problems with network traffik if too high. + # 0.001 = 1000/s + await asyncio.sleep(0.001) except RuntimeError: # The connection was closed, just exit the task return