Skip to content

Commit 8878460

Browse files
fix: callback inappropriately suppresses asyncio logs
We must use the private `_exception` attribute instead of `exception()` so asyncio does not set `task.__log_traceback = False` on the false assumption that the caller read the task Exception
1 parent 9ab48ab commit 8878460

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

async_lru/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,10 @@ def _cache_miss(self, key: Hashable) -> None:
178178
self.__misses += 1
179179

180180
def _task_done_callback(self, key: Hashable, task: "asyncio.Task[_R]") -> None:
181-
if task.cancelled() or task.exception() is not None:
181+
# We must use the private attribute instead of `exception()`
182+
# so asyncio does not set `task.__log_traceback = False` on
183+
# the false assumption that the caller read the task Exception
184+
if task.cancelled() or task._exception is not None:
182185
self.__cache.pop(key, None)
183186
return
184187

0 commit comments

Comments
 (0)