0
1
mirror of https://github.com/radio95-rnt/RadioPlayer.git synced 2026-02-27 06:03:52 +01:00
This commit is contained in:
2025-12-13 20:41:41 +01:00
parent e938be95c2
commit ebf46d6832

View File

@@ -11,7 +11,7 @@ from . import Track, PlayerModule, Path
MAIN_PATH_DIR = Path("/home/user/mixes") MAIN_PATH_DIR = Path("/home/user/mixes")
async def ws_handler(websocket: ServerConnection, shared_data: dict, imc_q: multiprocessing.Queue, ws_q: multiprocessing.Queue): async def ws_handler(websocket: ServerConnection, shared_data: dict, imc_q: multiprocessing.Queue):
try: try:
initial = { initial = {
"playlist": json.loads(shared_data.get("playlist", "[]")), "playlist": json.loads(shared_data.get("playlist", "[]")),
@@ -90,10 +90,10 @@ async def broadcast_worker(ws_q: multiprocessing.Queue, clients: set):
if msg is None: break if msg is None: break
payload = json.dumps(msg) payload = json.dumps(msg)
if clients: if clients:
await asyncio.gather( coros = []
*[_safe_send(ws, payload, clients) for ws in list(clients)], for ws in list(clients):
return_exceptions=True coros.append(_safe_send(ws, payload, clients))
) await asyncio.gather(*coros)
async def _safe_send(ws, payload: str, clients: set): async def _safe_send(ws, payload: str, clients: set):
@@ -118,7 +118,7 @@ def websocket_server_process(shared_data: dict, imc_q: multiprocessing.Queue, ws
async def handler_wrapper(websocket: ServerConnection): async def handler_wrapper(websocket: ServerConnection):
# register client # register client
clients.add(websocket) clients.add(websocket)
try: await ws_handler(websocket, shared_data, imc_q, ws_q) try: await ws_handler(websocket, shared_data, imc_q)
finally: finally:
await websocket.close(1001, "") await websocket.close(1001, "")
clients.discard(websocket) clients.discard(websocket)