blob: d47face205c8098ea1ae5acf36c74046eb415d04 [file] [log] [blame]
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00001\section{Built-in module \sectcode{select}}
2\bimodindex{select}
3
4This module provides access to the function \code{select} available in
5most \UNIX{} versions. It defines the following:
6
7\renewcommand{\indexsubitem}{(in module select)}
8\begin{excdesc}{error}
9The exception raised when an error occurs. The accompanying value is
10a pair containing the numeric error code from \code{errno} and the
11corresponding string, as would be printed by the C function
12\code{perror()}.
13\end{excdesc}
14
15\begin{funcdesc}{select}{iwtd\, owtd\, ewtd\, timeout}
16This is a straightforward interface to the \UNIX{} \code{select()}
17system call. The first three arguments are lists of `waitable
18objects': either integers representing \UNIX{} file descriptors or
19objects with a parameterless method named \code{fileno()} returning
20such an integer. The three lists of waitable objects are for input,
21output and `exceptional conditions', respectively. Empty lists are
22allowed. The optional last argument is a time-out specified as a
23floating point number in seconds. When the \var{timeout} argument
24is omitted the function blocks until at least one file descriptor is
25ready. A time-out value of zero specifies a poll and never blocks.
26
27The return value is a triple of lists of objects that are ready:
28subsets of the first three arguments. When the time-out is reached
29without a file descriptor becoming ready, three empty lists are
30returned.
31
32Amongst the acceptable object types in the lists are Python file
33objects (e.g. \code{sys.stdin}, or objects returned by \code{open()}
34or \code{posix.popen()}), socket objects returned by
35\code{socket.socket()}, and the module \code{stdwin} which happens to
36define a function \code{fileno()} for just this purpose. You may
37also define a \dfn{wrapper} class yourself, as long as it has an
38appropriate \code{fileno()} method (that really returns a \UNIX{} file
39descriptor, not just a random integer).
40\end{funcdesc}
41\ttindex{socket}
42\ttindex{stdwin}