This method is identical to `logger.warning()`, but will emit the warning with the same message only once Note: The cache is for the function arguments, so 2 different callers using the same arguments will hit the cache. The assumption here is that all warning messages are unique acros
(*args, **kwargs)
| 52 | |
| 53 | @functools.lru_cache(None) |
| 54 | def warning_once(*args, **kwargs): |
| 55 | """ |
| 56 | This method is identical to `logger.warning()`, but will emit the warning with the same message only once |
| 57 | |
| 58 | Note: The cache is for the function arguments, so 2 different callers using the same arguments will hit the cache. |
| 59 | The assumption here is that all warning messages are unique across the code. If they aren't then need to switch to |
| 60 | another type of cache that includes the caller frame information in the hashing function. |
| 61 | """ |
| 62 | logger.warning(*args, **kwargs) |
| 63 | |
| 64 | |
| 65 | logger.warning_once = warning_once |