From 1ea69d315a49376e32f1fba46ffa7d028eed8046 Mon Sep 17 00:00:00 2001 From: Lukas Senionis Date: Thu, 3 Sep 2026 01:44:20 +0300 Subject: Fix pyright annotation issue for __qualname__ (#959) --- backend/decky_loader/main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'backend/decky_loader/main.py') diff --git a/backend/decky_loader/main.py b/backend/decky_loader/main.py index 16caca2e..24115419 100644 --- a/backend/decky_loader/main.py +++ b/backend/decky_loader/main.py @@ -138,7 +138,17 @@ class PluginManager: tasks = all_tasks() current = current_task() async def cancel_task(task: Task[Any]): - name = task.get_coro().__qualname__ + task_coro = task.get_coro() + if not task_coro: + # Can be None in case asyncio.eager_task_factory is used in the future + return + + if sys.version_info >= (3, 12): + name = task_coro.__qualname__ + else: + # Before 3.12, the task_coro can be a generator and apparently it does not + # have __qualname__, so this workaround is needed... + name = getattr(task_coro, "__qualname__", task.get_name()) logger.debug(f"Cancelling task {name}") try: task.cancel() -- cgit v1.2.3