def _poll_for(fd, readable, writable, error, timeout):
    """
    @param fd: File descriptor (int).
    @param readable: Whether to wait for readability (bool).
    @param writable: Whether to wait for writability (bool).
    @param expiration: Deadline timeout (expiration time, in seconds (float)).

    @return True on success, False on timeout
    """
    event_mask = 0
    if readable:
        event_mask |= select.POLLIN
    if writable:
        event_mask |= select.POLLOUT
    if error:
        event_mask |= select.POLLERR

    pollable = select.poll()
    pollable.register(fd, event_mask)

    if timeout:
        event_list = pollable.poll(long(timeout * 1000))
    else:
        event_list = pollable.poll()

    return bool(event_list)