move send delay to relay

This commit is contained in:
Timothy Pogue 2022-10-10 23:32:10 -06:00
parent 5ada5eb540
commit eb8c89fe31
2 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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