16.1. select — Waiting for I/O completion¶
This module provides access to the :cfunc:`select` and :cfunc:`poll` functions available in most operating systems, :cfunc:`epoll` available on Linux 2.5+ and :cfunc:`kqueue` available on most BSD. 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:
-
exception
select.error¶ The exception raised when an error occurs. The accompanying value is a pair containing the numeric error code from :cdata:`errno` and the corresponding string, as would be printed by the C function :cfunc:`perror`.
-
select.epoll([sizehint=-1])¶ (Only supported on Linux 2.5.44 and newer.) Returns an edge polling object, which can be used as Edge or Level Triggered interface for I/O events; see section Edge and Level Trigger Polling (epoll) Objects below for the methods supported by epolling objects.
New in version 2.6:
New in version 2.6.
-
select.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 Polling Objects below for the methods supported by polling objects.
-
select.kqueue()¶ (Only supported on BSD.) Returns a kernel queue object; see section Kqueue Objects below for the methods supported by kqueue objects.
New in version 2.6:
New in version 2.6.