summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redis/asyncio/client.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/redis/asyncio/client.py b/redis/asyncio/client.py
index 9e16ee0..5de2ff9 100644
--- a/redis/asyncio/client.py
+++ b/redis/asyncio/client.py
@@ -702,6 +702,11 @@ class PubSub:
self.pending_unsubscribe_patterns = set()
def close(self) -> Awaitable[NoReturn]:
+ # In case a connection property does not yet exist
+ # (due to a crash earlier in the Redis() constructor), return
+ # immediately as there is nothing to clean-up.
+ if not hasattr(self, "connection"):
+ return
return self.reset()
async def on_connect(self, connection: Connection):