Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# `gevent.select` – Waiting for I/O completion

Waiting for I/O completion.

error

  alias of `OSError`

class poll

  Bases: `object`

  An implementation of `select.poll` that blocks only the current greenlet.

  With only one exception, the interface is the same as the standard library interface.

  Caution

  `POLLPRI` data is not supported.

  New in version 1.1b1.

  Changed in version 1.5: This is now always defined, regardless of whether the standard library defines `select.poll()` or not. Note that it may have different performance characteristics.

  modify(fd, eventmask)

    Change the set of events being watched on fd.

  poll(timeout=None)

    poll the registered fds.

    Changed in version 1.2a1: File descriptors that are closed are reported with POLLNVAL.

    Changed in version 1.3a2: Under libuv, interpret timeout values less than 0 the same as None, i.e., block. This was always the case with libev.

  register(fd, eventmask=<default value>)

    Register a file descriptor fd with the polling object.

    Future calls to the `poll`()` method will then check whether the file descriptor has any pending I/O events. fd can be either an integer, or an object with a `fileno()` method that returns an integer. File objects implement `fileno()`, so they can also be used as the argument (but remember that regular files are usually always ready).

    eventmask is an optional bitmask describing the type of events you want to check for, and can be a combination of the constants `POLLIN`, and `POLLOUT` (`POLLPRI` is not supported).

  unregister(fd)

    Unregister the fd.

    Changed in version 1.2a1: Raise a `KeyError` if fd was not registered, like the standard library. Previously gevent did nothing.

select(rlist, wlist, xlist, timeout=None)

  An implementation of `select.select` that blocks only the current greenlet.

  Caution

  xlist is ignored.

  Changed in version 1.2a1: Raise a `ValueError` if timeout is negative. This matches Python 3’s behaviour (Python 2 would raise a `select.error`). Previously gevent had undefined behaviour.

  Changed in version 1.2a1: Raise an exception if any of the file descriptors are invalid.