'Buffered read from node, potentially blocking.
maxbytes: maximum number of bytes to return'

def read(self, maxbytes=1024):

    count = len(self.readbuf)
    if (count < maxbytes):
        data = os.read(self.stdout.fileno(), (maxbytes - count))
        self.readbuf += data
    if (maxbytes >= len(self.readbuf)):
        result = self.readbuf
        self.readbuf = ''
    else:
        result = self.readbuf[:maxbytes]
        self.readbuf = self.readbuf[maxbytes:]
    return result
