def set_blocking(fd, blocking=True):

    old_flag = fcntl.fcntl(fd, fcntl.F_GETFL)

    if blocking:
        new_flag = old_flag & ~ os.O_NONBLOCK
    else:
        new_flag = old_flag | os.O_NONBLOCK

    fcntl.fcntl(fd, fcntl.F_SETFL, new_flag)

    return not bool(old_flag & os.O_NONBLOCK)
Set the given file-descriptor blocking or non-blocking.
dataset/ETHPy150Open d11wtq/dockerpty/dockerpty/io.py/set_blocking