diff --git a/redis/client.py b/redis/client.py index dc6693d111..1c4b5e890d 100755 --- a/redis/client.py +++ b/redis/client.py @@ -1215,6 +1215,7 @@ def reset(self): self.pending_unsubscribe_channels = set() self.patterns = {} self.pending_unsubscribe_patterns = set() + self.cmd_execution_health_check = True def close(self): self.reset() @@ -1258,8 +1259,11 @@ def execute_command(self, *args): # were listening to when we were disconnected self.connection.register_connect_callback(self.on_connect) connection = self.connection - kwargs = {'check_health': not self.subscribed} + kwargs = {'check_health': self.cmd_execution_health_check} self._execute(connection, connection.send_command, *args, **kwargs) + if self.cmd_execution_health_check is True: + # Run a health check only on the first command execution + self.cmd_execution_health_check = False def _disconnect_raise_connect(self, conn, error): """