Skip to content

Commit

Permalink
Make sure shutdown doesn't hang forever
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCat467 committed Jul 7, 2024
1 parent 5626049 commit 477f976
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/statusbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
)
Expand Down Expand Up @@ -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[
Expand Down

0 comments on commit 477f976

Please sign in to comment.