Copyright (C) 2000-2012 |
GNU Info (python2.1-lib.info)selectWaiting for I/O completion ========================== Wait for I/O completion on multiple streams. This module provides access to the `select()' and `poll()' functions available in most operating systems. Note that on Windows, it only works for sockets; on other operating systems, it also works for other file types (in particular, on UNIX, it works on pipes). It cannot be used on regular files to determine whether a file has grown since it was last read. The module defines the following: `error' The exception raised when an error occurs. The accompanying value is a pair containing the numeric error code from `errno' and the corresponding string, as would be printed by the C function `perror()'. `poll()' (Not supported by all operating systems.) Returns a polling object, which supports registering and unregistering file descriptors, and then polling them for I/O events; see section~Note: threading below for the methods supported by polling objects. `select(iwtd, owtd, ewtd[, timeout])' This is a straightforward interface to the UNIX `select()' system call. The first three arguments are lists of `waitable objects': either integers representing file descriptors or objects with a parameterless method named `fileno()' returning such an integer. The three lists of waitable objects are for input, output and `exceptional conditions', respectively. Empty lists are allowed, but acceptance of three empty lists is platform-dependent. (It is known to work on UNIX but not on Windows.) The optional TIMEOUT argument specifies a time-out as a floating point number in seconds. When the TIMEOUT argument is omitted the function blocks until at least one file descriptor is ready. A time-out value of zero specifies a poll and never blocks. The return value is a triple of lists of objects that are ready: subsets of the first three arguments. When the time-out is reached without a file descriptor becoming ready, three empty lists are returned. Amongst the acceptable object types in the lists are Python file objects (e.g. `sys.stdin', or objects returned by `open()' or `os.popen()'), socket objects returned by `socket.socket()', . You may also define a "wrapper" class yourself, as long as it has an appropriate `fileno()' method (that really returns a file descriptor, not just a random integer). *Note:* File objects on Windows are not acceptable, but sockets are. On Windows, the underlying `select()' function is provided by the WinSock library, and does not handle file desciptors that don't originate from WinSock. automatically generated by info2www version 1.2.2.9 |