Fix deprecation warnings for asyncio.iscoroutinefunction (#3054)
authorMarvin Schenkel <marvinschenkel@gmail.com>
Sat, 31 Jan 2026 08:14:06 +0000 (09:14 +0100)
committerGitHub <noreply@github.com>
Sat, 31 Jan 2026 08:14:06 +0000 (09:14 +0100)
Fix deprecation warnings for asyncio.iscoroutinefunciton.

music_assistant/controllers/webserver/controller.py
music_assistant/controllers/webserver/websocket_client.py
music_assistant/helpers/logging.py
music_assistant/mass.py
music_assistant/providers/snapcast/socket_server.py

index 7bb9a8059e2487e80289ad578f2b2570715179bf..27603e04c4cc788e726043f60e12a298f3d648f1 100644 (file)
@@ -10,6 +10,7 @@ from __future__ import annotations
 import asyncio
 import hashlib
 import html
+import inspect
 import os
 import urllib.parse
 from collections.abc import Awaitable, Callable
@@ -575,7 +576,7 @@ class WebserverController(CoreController):
             if hasattr(result, "__anext__"):
                 # handle async generator (for really large listings)
                 result = [item async for item in result]
-            elif asyncio.iscoroutine(result):
+            elif inspect.iscoroutine(result):
                 result = await result
             return web.json_response(result, dumps=json_dumps)
         except Exception as e:
index 610d9e087770a390239fc145511f6f1b0de98259..12700149a8eed08843ac6da4dadfb4186256a7df 100644 (file)
@@ -3,6 +3,7 @@
 from __future__ import annotations
 
 import asyncio
+import inspect
 import logging
 from concurrent import futures
 from contextlib import suppress
@@ -238,7 +239,7 @@ class WebsocketClientHandler:
                         )
                         items = []
                 result = items
-            elif asyncio.iscoroutine(result):
+            elif inspect.iscoroutine(result):
                 result = await result
             await self._send_message(SuccessResultMessage(msg.message_id, result))
         except Exception as err:
index 21362471f1b1f29e1f42b6535b962c3502403102..97116c3da83a3c3bd36911ba25403d881ed4baa6 100644 (file)
@@ -9,7 +9,6 @@ All rights reserved.
 
 from __future__ import annotations
 
-import asyncio
 import inspect
 import logging
 import logging.handlers
@@ -130,7 +129,7 @@ def catch_log_exception(
         check_func = check_func.func
 
     wrapper_func: Callable[..., None] | Callable[..., Coroutine[Any, Any, None]]
-    if asyncio.iscoroutinefunction(check_func):
+    if inspect.iscoroutinefunction(check_func):
         async_func = cast("Callable[..., Coroutine[Any, Any, None]]", func)
 
         @wraps(async_func)
index 4c7ebe7c3cc17fc25f91b01c4a98ff09f0ca6724..00d90486af6623aa031663978d937f175c8b4e15 100644 (file)
@@ -3,6 +3,7 @@
 from __future__ import annotations
 
 import asyncio
+import inspect
 import logging
 import os
 import pathlib
@@ -412,7 +413,7 @@ class MusicAssistant:
                 continue
             if not (id_filter is None or object_id in id_filter):
                 continue
-            if asyncio.iscoroutinefunction(cb_func):
+            if inspect.iscoroutinefunction(cb_func):
                 if TYPE_CHECKING:
                     cb_func = cast("Callable[[MassEvent], Coroutine[Any, Any, None]]", cb_func)
                 self.create_task(cb_func, event_obj)
@@ -466,10 +467,10 @@ class MusicAssistant:
                 return existing
         self.verify_event_loop_thread("create_task")
 
-        if asyncio.iscoroutinefunction(target):
+        if inspect.iscoroutinefunction(target):
             # coroutine function
             task = self.loop.create_task(target(*args, **kwargs))
-        elif asyncio.iscoroutine(target):
+        elif inspect.iscoroutine(target):
             # coroutine
             task = self.loop.create_task(target)
         elif callable(target):
@@ -526,7 +527,7 @@ class MusicAssistant:
             self._tracked_timers.pop(task_id)
             self.create_task(_target, *args, task_id=task_id, abort_existing=True, **kwargs)
 
-        if asyncio.iscoroutinefunction(target) or asyncio.iscoroutine(target):
+        if inspect.iscoroutinefunction(target) or inspect.iscoroutine(target):
             # coroutine function
             if TYPE_CHECKING:
                 target = cast("Coroutine[Any, Any, _R]", target)
index 04c5a2cfdf49f660e857a13e8d9164dc8684bd79..3f744a52e33879f258274e329ffca4ea33280551 100644 (file)
@@ -7,6 +7,7 @@ and Music Assistant, avoiding the need to expose the WebSocket API to the contro
 from __future__ import annotations
 
 import asyncio
+import inspect
 import json
 import logging
 from contextlib import suppress
@@ -169,7 +170,7 @@ class SnapcastSocketServer:
 
         # Execute the handler
         result = handler.target(**args)
-        if asyncio.iscoroutine(result):
+        if inspect.iscoroutine(result):
             result = await result
         return result