From aaa0389e2a65e4f324fb4a3e769db179e8d8995e Mon Sep 17 00:00:00 2001 From: dvora-h Date: Sun, 30 Apr 2023 16:46:44 +0300 Subject: [PATCH] clean warnings --- redis/asyncio/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis/asyncio/client.py b/redis/asyncio/client.py index 3e6626aedf..5fb94b3353 100644 --- a/redis/asyncio/client.py +++ b/redis/asyncio/client.py @@ -455,7 +455,7 @@ async def __aexit__(self, exc_type, exc_value, traceback): _DEL_MESSAGE = "Unclosed Redis client" def __del__(self, _warnings: Any = warnings) -> None: - if self.connection is not None: + if hasattr(self, "connection") and (self.connection is not None): _warnings.warn( f"Unclosed client session {self!r}", ResourceWarning, source=self )