diff --git a/redis/client.py b/redis/client.py index b12ad578d6..3b142177b4 100755 --- a/redis/client.py +++ b/redis/client.py @@ -1149,6 +1149,12 @@ def __del__(self): self.close() def close(self): + # 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 + conn = self.connection if conn: self.connection = None