From 198796ddb3800e190011da57c4f31d2d0c40a332 Mon Sep 17 00:00:00 2001 From: Mysty Date: Sat, 13 Jul 2024 11:49:03 +1000 Subject: [PATCH] Fix/inactive task error (#312) * Fix task cancelled error being raised in inactive player tasks. * Remove unnecessary else statement --- wavelink/player.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wavelink/player.py b/wavelink/player.py index d961ccb7..3f0d1fd2 100644 --- a/wavelink/player.py +++ b/wavelink/player.py @@ -169,8 +169,13 @@ def __init__( self._inactivity_wait: int | None = self._node._inactive_player_timeout def _inactivity_task_callback(self, task: asyncio.Task[bool]) -> None: - result: bool = task.result() - cancelled: bool = task.cancelled() + cancelled: bool = False + + try: + result: bool = task.result() + except asyncio.CancelledError: + cancelled = True + result = False if cancelled or result is False: logger.debug("Disregarding Inactivity Check Task <%s> as it was previously cancelled.", task.get_name())