nonblocking i/o on windows?

Skip Montanaro skip at pobox.com
Mon Mar 11 17:15:07 EST 2002


At the end of asyncore.py a non-blocking file_dispatcher class is defined
like so:

    class file_dispatcher (dispatcher):
        def __init__ (self, fd):
            dispatcher.__init__ (self)
            self.connected = 1
            # set it to non-blocking mode
            flags = fcntl.fcntl (fd, fcntl.F_GETFL, 0)
            flags = flags | os.O_NONBLOCK
            fcntl.fcntl (fd, fcntl.F_SETFL, flags)
            self.set_file (fd)

        def set_file (self, fd):
            self._fileno = fd
            self.socket = file_wrapper (fd)
            self.add_channel()

Unfortunately, this uses fcntl, which is only available on Unix systems.  Is
there something similar on Windows that will allow me to put a Python file
object in non-blocking mode?  I thought perhaps there would be something
defined in msvcrt, but I didn't see anything in the lib ref manual or the
msvcrt source.

Thx,

-- 
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)
"As often happens in Net communities, people find all kinds of energy to
compose incisive criticisms of the threads and postings of other members,
when they could be directing that energy towards brilliant new threads and
postings of their own." - Tom Neff




More information about the Python-list mailing list