changeset 3936:ebe45ea2df3b

tools (common/async_utils): set default `maxsize` to 50 in `async_lru`
author Goffi <goffi@goffi.org>
date Sat, 15 Oct 2022 20:37:00 +0200 (2022-10-15)
parents 80d29f55ba8b
children 5980ea188f87
files sat/tools/common/async_utils.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sat/tools/common/async_utils.py	Sat Oct 15 20:37:00 2022 +0200
+++ b/sat/tools/common/async_utils.py	Sat Oct 15 20:37:00 2022 +0200
@@ -27,8 +27,13 @@
 log = getLogger(__name__)
 
 
-def async_lru(maxsize: Optional[int] = None) -> Callable:
-    """Decorator to cache async function results using LRU algorithm"""
+def async_lru(maxsize: Optional[int] = 50) -> Callable:
+    """Decorator to cache async function results using LRU algorithm
+
+        @param maxsize: maximum number of items to keep in cache.
+            None to have no limit
+
+    """
     def decorator(func: Callable) -> Callable:
         cache = OrderedDict()
         async def wrapper(*args) -> Awaitable: