From 288cdac3e826a4fb67d8ba2c1fe98ea52f9fe658 Mon Sep 17 00:00:00 2001 From: kwzrd Date: Sat, 27 Mar 2021 11:59:22 +0100 Subject: Branding: ensure daemon logs exceptions --- bot/exts/backend/branding/_cog.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bot/exts/backend/branding/_cog.py b/bot/exts/backend/branding/_cog.py index d6c5b159b..57347b60e 100644 --- a/bot/exts/backend/branding/_cog.py +++ b/bot/exts/backend/branding/_cog.py @@ -477,19 +477,22 @@ class Branding(commands.Cog): """ log.trace("Daemon loop: calling daemon main") - await self.daemon_main() + try: + await self.daemon_main() + except Exception: + log.exception("Daemon loop: failed with an unhandled exception!") @daemon_loop.before_loop async def daemon_before(self) -> None: """ - Call `daemon_main` immediately, then block `daemon_loop` until the next-up UTC midnight. + Call `daemon_loop` immediately, then block the loop until the next-up UTC midnight. - The first iteration will be invoked manually such that synchronisation happens immediately after daemon start. + The first iteration is invoked directly such that synchronisation happens immediately after daemon start. We then calculate the time until the next-up midnight and sleep before letting `daemon_loop` begin. """ - log.info("Daemon before: synchronising guild") + log.trace("Daemon before: performing start-up iteration") - await self.daemon_main() + await self.daemon_loop() log.trace("Daemon before: calculating time to sleep before loop begins") now = datetime.utcnow() -- cgit v1.2.3