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())
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: