Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions async_lru/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,24 @@ def _task_done_callback(
) -> None:
self.__tasks.discard(task)

cache = self.__cache

if task.cancelled():
fut.cancel()
self.__cache.pop(key, None)
cache.pop(key, None)
return

exc = task.exception()
if exc is not None:
fut.set_exception(exc)
self.__cache.pop(key, None)
cache.pop(key, None)
return

cache_item = self.__cache.get(key)
if self.__ttl is not None and cache_item is not None:
cache_item = cache.get(key)
ttl = self.__ttl
if ttl is not None and cache_item is not None:
loop = asyncio.get_running_loop()
cache_item.later_call = loop.call_later(
self.__ttl, self.__cache.pop, key, None
)
cache_item.later_call = loop.call_later(ttl, cache.pop, key, None)

fut.set_result(task.result())

Expand Down
Loading