def readchar(fd):
    """
    Read a character from the PTY at `fd`, or nothing if no data to read.
    """

    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 __HOLE__ as ex:
                    if ex.errno == errno.EIO:
                        # exec ends with:
                        #   OSError: [Errno 5] Input/output error
                        # no idea why
                        return ""
                    raise
dataset/ETHPy150Open d11wtq/dockerpty/tests/util.py/readchar