def readchar(fd):

    while True:
        ready = wait(fd)
        if len(ready) == 0:
            return six.binary_type()
        else:
            for s in ready:
                try:
                    return os.read(s, 1)
                except OSError as ex:
                    if ex.errno == errno.EIO:
                        # exec ends with:
                        #   OSError: [Errno 5] Input/output error
                        # no idea why
                        return ""
                    raise
Read a character from the PTY at `fd`, or nothing if no data to read.
dataset/ETHPy150Open d11wtq/dockerpty/tests/util.py/readchar