def check_health(self):
        "Check the health of the connection with a PING/PONG"
        if self.health_check_interval and time() > self.next_health_check:
            try:
                self.send_command('PING', check_health=False)
                if nativestr(self.read_response()) != 'PONG':
                    raise ConnectionError(
                        'Bad response from PING health check')
            except (ConnectionError, TimeoutError) as ex:
                self.disconnect()
                self.send_command('PING', check_health=False)
                if nativestr(self.read_response()) != 'PONG':
                    raise ConnectionError(
                        'Bad response from PING health check')
Check the health of the connection with a PING/PONG
stackoverflow/venv/lib/python3.6/site-packages/redis/connection.py