From 477f976b25535043c87f7e24cb16427da1c70351 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Sun, 7 Jul 2024 15:41:42 -0500 Subject: [PATCH] Make sure shutdown doesn't hang forever --- src/statusbot/bot.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/statusbot/bot.py b/src/statusbot/bot.py index a5df8a2..1441efe 100644 --- a/src/statusbot/bot.py +++ b/src/statusbot/bot.py @@ -1997,6 +1997,7 @@ async def process_command_message( midx = int(mode.lower() == "guild") if self.stopped.is_set() and midx: + # Ignore if shutting down and in guild await message.channel.send( f"{__title__} is in the process of shutting down.", ) @@ -2161,9 +2162,11 @@ async def close(self) -> None: # await asyncio.gather(*coros) print("Waiting to acquire updating lock...\n") - with self.updating: - print("Closing...") - await discord.Client.close(self) + while self.updating.locked(): + print("Mid update, waiting for complete...") + await asyncio.sleep(1) + print("Closing...") + await discord.Client.close(self) def setup_bot(loop: asyncio.AbstractEventLoop) -> tuple[