diff --git a/scanner/scanner/cache.py b/scanner/scanner/cache.py index b21a9851..0f02447d 100644 --- a/scanner/scanner/cache.py +++ b/scanner/scanner/cache.py @@ -5,7 +5,7 @@ from typing import Any, Optional, Tuple type Cache = dict[Any, Tuple[Optional[asyncio.Event], Optional[datetime], Any]] -def cache(ttl: timedelta, cache: Cache={}, typed=False): +def cache(ttl: timedelta, cache: Optional[Cache] = None, typed=False): """ A cache decorator for async methods. If the same method is called twice with the same args, the underlying method will only be called once and the first @@ -17,6 +17,9 @@ def cache(ttl: timedelta, cache: Cache={}, typed=False): """ + if cache is None: + cache = {} + def wrap(f): @wraps(f) async def wrapper(*args, **kwargs):