0
1
mirror of https://github.com/radio95-rnt/RadioPlayer.git synced 2026-02-26 21:53:54 +01:00
This commit is contained in:
2025-12-13 20:42:20 +01:00
parent ebf46d6832
commit ffcc2b56bb

View File

@@ -85,15 +85,15 @@ async def broadcast_worker(ws_q: multiprocessing.Queue, clients: set):
""" """
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
while True: while True:
try: msg = asyncio.wait_for(loop.run_in_executor(None, ws_q.get), 1.0) try: msg = await asyncio.wait_for(loop.run_in_executor(None, ws_q.get), 1.0)
except asyncio.TimeoutError: continue except asyncio.TimeoutError: continue
if msg is None: break if msg is None: break
payload = json.dumps(msg) payload = json.dumps(msg)
if clients: if clients:
coros = [] await asyncio.gather(
for ws in list(clients): *[_safe_send(ws, payload, clients) for ws in list(clients)],
coros.append(_safe_send(ws, payload, clients)) return_exceptions=True
await asyncio.gather(*coros) )
async def _safe_send(ws, payload: str, clients: set): async def _safe_send(ws, payload: str, clients: set):