diff --git a/rediscluster/client.py b/rediscluster/client.py index 844cb4c9..213953a3 100644 --- a/rediscluster/client.py +++ b/rediscluster/client.py @@ -710,7 +710,8 @@ def _execute_command(self, *args, **kwargs): redirect_addr, asking = "{0}:{1}".format(e.host, e.port), True except BaseException as e: log.exception("BaseException") - connection.disconnect() + if connection is not None: + connection.disconnect() raise e finally: if connection is not None: