From 182c25242aad35c68c60bf5e1c8d6bbece8ea516 Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Thu, 12 Dec 2024 14:33:02 +0100 Subject: [PATCH] Fix --- .../stream_notifications/twitch/webhook.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/modules/stream_notifications/twitch/webhook.py b/src/modules/stream_notifications/twitch/webhook.py index 051382a..ec211a0 100644 --- a/src/modules/stream_notifications/twitch/webhook.py +++ b/src/modules/stream_notifications/twitch/webhook.py @@ -117,6 +117,19 @@ class TwitchService: await self.twitch.refresh_used_token() logger.info("Token refreshed") + async def stop(self, eventsub: EventSubWebhook): + self.failed = True + + try: + await eventsub.stop() + except Exception as e: + logger.error(e) + + try: + await self.twitch.close() + except Exception as e: + logger.error(e) + async def run(self) -> NoReturn: eventsub = EventSubWebhook( callback_url=config.TWITCH_CALLBACK_URL, @@ -139,10 +152,7 @@ class TwitchService: await self._check_token() finally: - await eventsub.stop() - await self.twitch.close() - - raise RuntimeError("Twitch service stopped") + await self.stop(eventsub) @classmethod async def start(cls):