From 5a06a6baab2e3d55bc98618edf36e0438a44ff28 Mon Sep 17 00:00:00 2001 From: Andrea Spacca Date: Fri, 19 Aug 2022 10:05:30 +0900 Subject: [PATCH] the order matters --- modules/tautulli.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/tautulli.py b/modules/tautulli.py index 1d3a2ad..425fd68 100644 --- a/modules/tautulli.py +++ b/modules/tautulli.py @@ -20,16 +20,19 @@ nest_asyncio.apply() rooms = dict() global_bot = None +send_entry_lock = asyncio.Lock() + async def send_entry(blob, content_type, fmt_params, rooms): - for room_id in rooms: - room = MatrixRoom(room_id=room_id, own_user_id=os.getenv("BOT_OWNERS"), - encrypted=rooms[room_id]) - if blob and content_type: - await global_bot.upload_and_send_image(room, blob, text="", blob=True, blob_content_type=content_type) + async with send_entry_lock: + for room_id in rooms: + room = MatrixRoom(room_id=room_id, own_user_id=os.getenv("BOT_OWNERS"), + encrypted=rooms[room_id]) + if blob and content_type: + await global_bot.upload_and_send_image(room, blob, text="", blob=True, blob_content_type=content_type) - await global_bot.send_html(room, msg_template_html.format(**fmt_params), - msg_template_plain.format(**fmt_params)) + await global_bot.send_html(room, msg_template_html.format(**fmt_params), + msg_template_plain.format(**fmt_params)) def get_image(img=None, width=1000, height=1500):