async def METHOD_NAME(self, session_id, connection, timeout):
    buffer = 4096
    data = b''
    waited_seconds = 0
    time.sleep(0.1)  # initial wait for fast operations.
    while True:
        try:
            part = connection.recv(buffer)
            data += part
            if len(part) < buffer:
                break
        except BlockingIOError as err:
            if waited_seconds < timeout:
                time.sleep(1)
                waited_seconds += 1
            else:
                self.log.error("Timeout reached for session %s", session_id)
                return json.dumps(dict(status=1, pwd='~$ ', response=str(err)))
    return str(data, 'utf-8')