def next_command(self):
        "Parse the response from a monitor command"
        response = self.connection.read_response()
        if isinstance(response, bytes):
            response = self.connection.encoder.decode(response, force=True)
        command_time, command_data = response.split(' ', 1)
        m = self.monitor_re.match(command_data)
        db_id, client_info, command = m.groups()
        command = ' '.join(self.command_re.findall(command))
        command = command.replace('\\"', '"').replace('\\\\', '\\')

        if client_info == 'lua':
            client_address = 'lua'
            client_port = ''
            client_type = 'lua'
        elif client_info.startswith('unix'):
            client_address = 'unix'
            client_port = client_info[5:]
            client_type = 'unix'
        else:
            # use rsplit as ipv6 addresses contain colons
            client_address, client_port = client_info.rsplit(':', 1)
            client_type = 'tcp'
        return {
            'time': float(command_time),
            'db': int(db_id),
            'client_address': client_address,
            'client_port': client_port,
            'client_type': client_type,
            'command': command
        }
Parse the response from a monitor command
stackoverflow/venv/lib/python3.6/site-packages/redis/client.py