Rate-limit EMC startup to avoid overwelming the queue

This commit is contained in:
Matthias 2022-10-17 20:43:32 +02:00
parent 880ddccaa8
commit c7fff1213c
1 changed files with 3 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import asyncio
import logging
from typing import Any, Dict
@ -89,6 +90,8 @@ async def _process_consumer_request(
for _, message in analyzed_df.items():
response = WSAnalyzedDFMessage(data=message)
await channel.send(response.dict(exclude_none=True))
# Throttle the messages to 50/s
await asyncio.sleep(0.02)
@router.websocket("/message/ws")