From a6cc75d36a8cb0aae36ad527d73838d529fdd54e Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Thu, 30 Apr 2020 04:39:38 +0200 Subject: [PATCH] optimize broadcast to serialize once --- MultiServer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MultiServer.py b/MultiServer.py index c88a91d9..4e6261e6 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -163,15 +163,17 @@ async def send_json_msgs(client: Client, msg: str): def broadcast_all(ctx: Context, msgs): + msgs = json.dumps(msgs) for client in ctx.clients: if client.auth: - asyncio.create_task(send_msgs(client, msgs)) + asyncio.create_task(send_json_msgs(client, msgs)) def broadcast_team(ctx: Context, team, msgs): + msgs = json.dumps(msgs) for client in ctx.clients: if client.auth and client.team == team: - asyncio.create_task(send_msgs(client, msgs)) + asyncio.create_task(send_json_msgs(client, msgs)) def notify_all(ctx : Context, text): logging.info("Notice (all): %s" % text)