Reading from stdin

Hendrik van Rooyen mail at microcorp.co.za
Thu Oct 9 22:53:57 CEST 2008


Luis Zarrabeitia wrote:

>But it doesn't say how to put the file object in non-blocking mode. (I was 
>trying to put the file object in non-blocking mode to test next()'s 
>behavior). ??Ideas?

# Some magic to make a file non blocking - from the internet

def unblock(f):
    """Given file 'f', sets its unblock flag to true."""

    fcntl.fcntl(f.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)

- Hendrik





More information about the Python-list mailing list