Filter slow callback logging for buffered_generator
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Thu, 4 Dec 2025 08:55:42 +0000 (09:55 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Thu, 4 Dec 2025 08:55:42 +0000 (09:55 +0100)
music_assistant/__main__.py
music_assistant/helpers/buffered_generator.py

index 956ed2c2fdd70235745262841247548d29d7232f..41cb778a29c3b0276d936e8c16f0e2e2e031f840 100644 (file)
@@ -140,9 +140,11 @@ def setup_logger(data_path: str, level: str = "DEBUG") -> logging.Logger:
 
         def filter(self, record: logging.LogRecord) -> bool:
             """Return False to suppress the log record."""
-            return not (
-                record.levelno == logging.WARNING and "buffered.<locals>.producer()" in record.msg
-            )
+            if record.levelno != logging.WARNING:
+                return True
+            # Check the formatted message, not the format string
+            msg = record.getMessage()
+            return "buffered.<locals>.producer()" not in msg
 
     logging.getLogger("asyncio").addFilter(BufferedGeneratorFilter())
 
index 9a16823bdaeb63b44fa9b6ec2ce830e1455b85f0..e8e2fda4d63d434bf416aafdc24319ab7600836b 100644 (file)
@@ -54,7 +54,13 @@ async def buffered(
         return
 
     async def producer() -> None:
-        """Read from the original generator and fill the buffer."""
+        """Read from the original generator and fill the buffer.
+
+        Note: When the buffer is full, buffer.put() will naturally wait for the consumer
+        to drain items. This is the intended buffering behavior and may trigger asyncio
+        "slow callback" warnings (typically 0.1-0.2s) which are harmless and expected.
+        These warnings are filtered out in the main logging configuration.
+        """
         nonlocal producer_error
         generator_consumed = False
         try: