Log a warning message only once per unique message. Uses a global set to track messages that have already been logged to prevent duplicate warning messages from cluttering the output. Args: logger_instance: The logger instance to use for warning. msg: The warning messag
(logger_instance: logging.Logger, msg: str)
| 4316 | |
| 4317 | |
| 4318 | def warn_once(logger_instance: logging.Logger, msg: str) -> None: |
| 4319 | """Log a warning message only once per unique message. |
| 4320 | |
| 4321 | Uses a global set to track messages that have already been logged |
| 4322 | to prevent duplicate warning messages from cluttering the output. |
| 4323 | |
| 4324 | Args: |
| 4325 | logger_instance: The logger instance to use for warning. |
| 4326 | msg: The warning message to log. |
| 4327 | """ |
| 4328 | if msg not in _warn_once_logged: |
| 4329 | logger_instance.warning(msg) |
| 4330 | _warn_once_logged.add(msg) |
| 4331 | |
| 4332 | |
| 4333 | # Named tuple for passing memory stats for logging |